ConnectAsPrivilege: DalConnectAsPrivilegeType;
ConnectAsPrivilege: Prognoz.Platform.Interop.Dal.DalConnectAsPrivilegeType;
The ConnectAsPrivilege property determines connection to the server of databases with the specified privilege.
Connection with privileges may require on executing operations in Foresight Analytics Platform that require the parameters specification for the credential with Oracle administrator rights enabled; for example, when the SYSTEM user account is locked because of security requirements and only the SYS user account is active.
To execute the example make sure that repository is on the Oracle server (Oracle DBMS type is 9.x\10.x\11.x) and there is a SYS user with the Password password on the server.
Add the Metabase, Dal system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
MbDef: IMetabaseDefinition;
Pack: ISecurityPackage;
Creds: ICredentials;
Se: IMetabaseSecurity;
Us: IMetabaseUser;
UsUpd: IMetabaseUsersUpdate;
Lic: Object;
Begin
Mb := MetabaseClass.Active;
// Get license to work with security manager
Lic := Mb.RequestLicense(UiLicenseFeatureType.Adm);
MbDef := Mb.Definition;
Pack := MbDef.Manager.Packs.FindById(MbDef.SecurityPackage).Package;
// Create password credentials
Creds := Pack.CreateCredentials(AuthenticationMode.Password);
// Set connection method with privilege 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;
// Update users
Se := Mb.Security;
UsUpd := Se.CreateUsersUpdate;
// Select all the users for the update
For Each Us In Se.Users Do
UsUpd.Add(Us);
End for;
// Update selected users
Se.UpdateUsers(UsUpd);
// Save changes
Se.Apply;
// Check in license
Lic := Null;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.ForeSystem;
…
Public Shared Sub Main(Params : StartParams);
Var
Mb: IMetabase;
MbDef: IMetabaseDefinition;
Pack: ISecurityPackage;
Creds: ICredentials;
Se: IMetabaseSecurity;
Us: IMetabaseUser;
UsUpd: IMetabaseUsersUpdate;
Lic: Object;
Begin
Mb := Params.Metabase;
// Get license to work with security manager
Lic := Mb.RequestLicense(UiLicenseFeatureType.lftAdm);
MbDef := Mb.Definition;
Pack := MbDef.Manager.Packs.FindById(MbDef.SecurityPackage).Package;
// Create password credentials
Creds := Pack.CreateCredentials(AuthenticationMode.amPassword);
// Set connection method with privilege 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();
// Select all the users for the update
For Each Us In Se.Users Do
UsUpd.Add(Us);
End for;
// Update selected users
Se.UpdateUsers(UsUpd);
// Save changes
Se.Apply();
// Check in license
Lic := Null;
End Sub;
After executing this example all repository users are updated. To connect to repository, credentials of the user with the SYSDBA privilege are specified.
See also: