ConnectAsPrivilege: DalConnectAsPrivilegeType;
ConnectAsPrivilege: Prognoz.Platform.Interop.Dal.DalConnectAsPrivilegeType;
The ConnectAsPrivilege property determines connection to the server of databases with the specified privilege.
A privileged connection may be required when the user needs to perform some operations in Prognoz Platform 9 that require specifying credentials of Oracle administrator account, for example, when the SYSTEM user is blocked due to security policy and only the SYS user is available.
To execute the example, connect the Metabase, Dal system assemblies to the module. It is supposed that the repository is stored on the Oracle (of DBMS Oracle 9.x\10.x\11.x type) server, the SYS user with the Password password is present in the server user list.
Sub UserProc;
Var
Mb: IMetabase;
MbDef: IMetabaseDefinition;
Pack: ISecurityPackage;
Creds: ICredentials;
Se: IMetabaseSecurity;
Us: IMetabaseUser;
UsUpd: IMetabaseUsersUpdate;
Begin
Mb := MetabaseClass.Active;
MbDef := Mb.Definition;
Pack := MbDef.Manager.Packs.FindById(MbDef.SecurityPackage).Package;
// Password credentials were created
Creds := Pack.CreateCredentials(AuthenticationMode.Password);
// The connection method is set with the enabled privileges of SYSDBA
Creds.ConnectAsPrivilege := DalConnectAsPrivilegeType.SYSDBA;
(Creds As IPasswordCredentials).UserName := "SYS";
(Creds As IPasswordCredentials).Password := "Password";
// Place credentials to the cache for usage on connecting for creating/editing users of the DBMS
Mb.LogonSession.Credentials("$SYSTEM", True) := Creds;
// Users updating
Se := Mb.Security;
UsUpd := Se.CreateUsersUpdate;
// Selecting all the users for the update
For Each Us In Se.Users Do
UsUpd.Add(Us);
End for;
// Updating the selected users
Se.UpdateUsers(UsUpd);
End Sub UserProc;
After executing the example all users of the repository will be updated, for the connection the credentials of the user with SYSDBA privilege were specified.
To execute the example, connect the Metabase, Dal system assemblies to the module. It is supposed that the repository is stored on the Oracle (of DBMS Oracle 9.x\10.x\11.x type) server, the SYS user with the Password password is present in the server user list.
Public Shared Sub Main(Params : StartParams);
Var
Mb: IMetabase;
MbDef: IMetabaseDefinition;
Pack: ISecurityPackage;
Creds: ICredentials;
Se: IMetabaseSecurity;
Us: IMetabaseUser;
UsUpd: IMetabaseUsersUpdate;
Begin
Mb := Params.Metabase;
MbDef := Mb.Definition;
Pack := MbDef.Manager.Packs.FindById(MbDef.SecurityPackage).Package;
// Password credentials were created
Creds := Pack.CreateCredentials(AuthenticationMode.amPassword);
// The connection method is set with the enabled privileges of SYSDBA
Creds.ConnectAsPrivilege := DalConnectAsPrivilegeType.dcaptSYSDBA;
(Creds As IPasswordCredentials).UserName := "SYS";
(Creds As IPasswordCredentials).Password := "Password";
// Place credentials to the cache for usage on connecting for creating/editing users of the DBMS
Mb.LogonSession.Credentials["$SYSTEM", True] := Creds;
// Users updating
Se := Mb.Security;
UsUpd := Se.CreateUsersUpdate();
// Selecting all the users for the update
For Each Us In Se.Users Do
UsUpd.Add(Us);
End for;
// Updating the selected users
Se.UpdateUsers(UsUpd);
End Sub;
After executing the example all users of the repository will be updated, for the connection the credentials of the user with SYSDBA privilege were specified.
See also: