IDalConnectionDescriptor2.ConnectAsPrivilege

Fore Syntax

ConnectAsPrivilege: DalConnectAsPrivilegeType;

Fore.NET Syntax

ConnectAsPrivilege: Prognoz.Platform.Interop.Dal.DalConnectAsPrivilegeType;

Description

The ConnectAsPrivilege property determines connection to the database server with the specified privilege.

Comments

Connection with the privilege can be set only for Oracle servers Oracle 9.x\10.x\11.x.

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.

Fore Example

Connect the Metabase and Dal system assemblies to the module to execute the example. It is supposed that the repository is located on the Oracle server (Oracle 9.x\10.x\11.x DBMS type), there is the SYS user with the Password password, and there is a table with the Table identifier in the repository.

Sub UserProc;
Var
    MB: IMetabase;
    Driv: IDalDriver;
    Connect: IDalConnection;
    Connect2: IDalConnectionDescriptor2;
    Command: IDalCommand;
    ConnectDesc: IDalConnectionDescriptor;
    ConnectDescParams: IDalConnectionDescriptorParams;
Begin
    MB := MetabaseClass.Active;
    Driv := New DalOrcl8Driver.Create;
    ConnectDesc := Driv.CreateDescriptor;
    ConnectDescParams := ConnectDesc.Params;
    ConnectDescParams.Find("User Name").Value := "SYS";
    ConnectDescParams.Find("Password").Value := "Password";
    ConnectDescParams.Find("Host BSTR").Value := "test";
    ConnectDescParams.Find("Schema").Value := "PPRepository";
    //User with the SYS privilege
    Connect2 := ConnectDesc As IDalConnectionDescriptor2;
    Connect2.ConnectAsPrivilege := DalConnectAsPrivilegeType.SYSOPER;
    Connect := ConnectDesc.CreateConnection;
    Command := Connect.CreateCommand;
    Command.SQL := "select * from Table";
    Connect.StartTransaction;
    Command.Execute;
    Connect.Commit;
    Command.Close;
    Connect.Close;
End Sub UserProc;

After executing this example the SQL query is executed, the user account credentials with the SYSOPER privilege are defined for connection.

Fore.NET example

Add a link to the Dal system assembly to execute the example. It is supposed that the repository is located on the Oracle server (Oracle 9.x\10.x\11.x DBMS type), there is the SYS user with the Password password, and there is a table with the Table identifier in the repository.

The specified procedure is an entry point for the .NET assembly.

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Dal;

Public Shared Sub Main(Params : StartParams);
Var
    MB: IMetabase;
    Driv: IDalDriver;
    Connect: IDalConnection;
    Connect2: IDalConnectionDescriptor2;
    Command: IDalCommand;
    ConnectDesc: IDalConnectionDescriptor;
    ConnectDescParams: IDalConnectionDescriptorParams;
Begin
    MB := Params.Metabase;
    Driv := New DalOrcl8Driver.Create();
    ConnectDesc := Driv.CreateDescriptor();
    ConnectDescParams := ConnectDesc.Params;
    ConnectDescParams.Find("User Name").Value := "SYS";
    ConnectDescParams.Find("Password").Value := "test";
    ConnectDescParams.Find("Host BSTR").Value := "test";
    ConnectDescParams.Find("Schema").Value := "PPRepository";
    //User with the SYS privilege
    Connect2 := ConnectDesc As IDalConnectionDescriptor2;
    Connect2.ConnectAsPrivilege := DalConnectAsPrivilegeType.dcaptSYSOPER;
    Connect := ConnectDesc.CreateConnection();
    Command := Connect.CreateCommand();
    Command.SQL := "select * from Table";
    Connect.StartTransaction();
    Command.Execute();
    Connect.Commit();
    Command.Close();
    Connect.Close();
End Sub;

After executing this example the SQL query is executed, the user account credentials with the SYSOPER privilege are defined for connection.

See also:

IDalConnectionDescriptor2