Advertisement
Advertisement
| 09.01.2008 at 12:38AM PDT, ID: 23693045 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: |
create or replace package body USER_MANAGER is
procedure Create_User(userN in varchar2, passwd in varchar2,
userprofile in varchar2,
returnValue out integer,
errormessage out varchar2
)
as
UserExists integer:=0;
profileExists integer:=0;
dynString varchar2(1000);
begin
begin
select 1 into UserExists from dual
where exists(select user_id from sys.all_users U where
U.username=userN);
exception when NO_DATA_FOUND then
UserExists:=0;
end;
if UserExists=0 then
dynString:='CREATE USER ' || userN || ' IDENTIFIED BY ' || passwd;
if userprofile<>'' and userprofile is not null then
select 1 into profileExists from dual
where exists(select P.profile from SYS.DBA_PROFILES P where P.profile=userprofile);
if profileExists=1 then
dynString:=dynString || ' PROFILE ' || userprofile;
else
returnValue:=-1;
errormessage:='Ky profil nuk egziston!!!';
--return;
end if;
end if;
execute immediate dynString;
dynString:='GRANT CONNECT to ' || userN;
execute immediate dynString;
returnValue:=0;
else
returnValue:=-1;
errormessage:='Perdorues me kete emer egziston!!!';
end if;
GrantPermissionsUser('DAP',userN,'VIEW','SELECT',returnValue,errormessage);
GrantPermissionsUser('DAP',userN,'FUNCTION','EXECUTE',returnValue,errormessage);
GrantPermissionsUser('DAP',userN,'PROCEDURE','EXECUTE',returnValue,errormessage);
GrantPermissionsUser('DAP',userN,'PACKAGE','EXECUTE',returnValue,errormessage);
GrantPermissionsUser('DAP',userN,'TABLE','SELECT',returnValue,errormessage);
GrantPermissionsUser('DAP',userN,'TYPE','EXECUTE',returnValue,errormessage);
exception when others then
returnValue:=SQLCODE;
errormessage:='Error ne krijimin e perdoruesit: ' || SQLERRM;
end Create_User;
procedure Create_Role(roleName in varchar2, returnValue out integer, errormessage out varchar2)
as
existsRole integer:=0;
dynString varchar2(1000);
begin
begin
select 1 into existsRole from dual
where exists(select role from sys.dba_roles where role=roleName);
exception when NO_DATA_FOUND then
existsRole:=0;
end;
if existsRole=0 then
dynString:='CREATE ROLE ' || roleName || ' NOT IDENTIFIED';
execute immediate dynString;
returnValue:=0;
else
returnValue:=-1;
errormessage:='Role me kete emer egziston!!!';
end if;
exception when others then
returnValue:=SQLCODE;
errormessage:='Error ka ndodhur ne krijimin e rolit: ' || SQLERRM;
end Create_Role;
procedure CrateSynonyms(userName in varchar2, typeSynonym in varchar2,
returnValue out integer, errormessage out varchar2)
as
dynString varchar2(1000);
UserExists integer:=0;
SynExists integer:=0;
begin
begin
select 1 into UserExists from dual
where exists(select user_id from sys.all_users U where
U.username=userName);
exception when NO_DATA_FOUND then
UserExists:=0;
end;
if UserExists=1 then
for idx in (select owner,
object_name,
subobject_name,
object_id,
data_object_id,
object_type,
created,
last_ddl_time,
timestamp,
status,
temporary,
generated,
secondary
from
sys.all_objects
where owner=userName and (object_type='PACKAGE' or object_type='VIEW'
or object_type='FUNCTION' or object_type='TABLE' or
object_type='TYPE'or object_type='PROCEDURE' or object_type='PACKAGE BODY'
)) loop
begin
select 1 into SynExists from dual
where
exists(select synonym_name from sys.all_synonyms where synonym_name=idx.object_name) ;
exception when NO_DATA_FOUND then
SynExists:=0;
end;
if SynExists=0 then
dynString:='CREATE PUBLIC SYNONYM ' || idx.object_name || ' FOR ' || userName || '.' || idx.object_name;
execute immediate dynString;
end if;
end loop ;
end if;
end CrateSynonyms;
procedure GrantPermissionsUser(ownerName in varchar2, userName in varchar2,
objectType in varchar2, accessType in varchar2,
returnValue out integer,
errormessage out varchar2)
as
dynString varchar2(1000);
UserExists integer:=0;
OwnerExists integer:=0;
SynExists integer:=0;
permGranted integer:=0;
begin
begin
select 1 into UserExists from dual
where exists(select user_id from sys.all_users U where
U.username=userName);
exception when NO_DATA_FOUND then
returnValue:=-1;
errormessage:='Error. Nuk gjej kete perdorues!!!';
end;
begin
select 1 into OwnerExists from dual
where exists(select user_id from sys.all_users U where
U.username=ownerName);
exception when NO_DATA_FOUND then
returnValue:=-1;
errormessage:='Error. Nuk gjej kete Owner!!!';
end;
if UserExists=1 and OwnerExists=1 then
for idx in (select owner,
object_name,
subobject_name,
object_id,
data_object_id,
object_type,
created,
last_ddl_time,
timestamp,
status,
temporary,
generated,
secondary
from
sys.all_objects
where owner=ownerName and object_type=objectType) loop
begin
select 1 into permGranted from dual
where
exists(select table_name from SYS.Dba_Tab_Privs where OWNER=ownerName and table_name=idx.object_name
and GRANTEE=userName) ;
exception when NO_DATA_FOUND then
permGranted:=0;
end;
if permGranted=0 then
dynString:='GRANT '|| accessType || ' ON ' || idx.object_name || ' TO ' || userName;
execute immediate dynString;
end if;
end loop;
end if;
exception when others then
returnValue:=SQLCODE;
errormessage:='Error ne dhenien permissions perdoruesit: ' || SQLERRM;
end GrantPermissionsUser;
procedure AssignUserInstGroup(SID in integer, grpID in char, userID in integer,
returnValue out integer,
errorMessage out varchar2 )
as
exist integer:=0;
begin
begin
select 1 into exist from dual
where exists(select G.Code_p_s from v_user_inst_groups G where G.Code_p_s=grpID);
exception
when NO_DATA_FOUND then
exist:=0;
end;
if exist=0 then
insert into instgroup_managment
(
user_id,
code_p_s,
date_created,
created_by
)
values
(
SID,
grpID,
CURRENT_DATE,
userID
);
end if;
errorMessage:='';
returnValue:=0;
exception
when others then
errorMessage:='Error database!!! Nuk mund lidh perdoruesin me Grupin!!!';
returnValue:=-1;
end AssignUserInstGroup;
end USER_MANAGER;
|