IMetabaseSecurity.AddTemporaryUser

Syntax

AddTemporaryUser(UserName: String, Period: Integer):IMetabaseUser;

AddTemporaryUser(System.String, System.Int32): Prognoz.Platform.Interop.Metabase.IMetabaseUser;

Description

The AddTemporaryUser method adds temporary user with specified period of use in days.

Example

To execute the example, add links to the Metabase, ForeSystem (for the Fore.NET example) system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    User: IMetabaseUser;
    Data: ISecurityPackageUserData;
    PS: IPasswordCredentials;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Get license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MS := MB.Security;
    
// Add a user use period
    User := MS.AddTemporaryUser("USERNAME"2);
    Data := User.PackageData;
    PS := Data.Credentials 
As IPasswordCredentials;
    
// Set password
    PS.Password := "Password";
    
// Save changes
    MS.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;
    MS: IMetabaseSecurity;
    User: IMetabaseUser;
    Data: ISecurityPackageUserData;
    PS: IPasswordCredentials;
    Lic: Object;
Begin
    MB := Params.Metabase;
    
// Get license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
    MS := MB.Security;
    
// Add a user use period
    User := MS.AddTemporaryUser("USERNAME"2);
    Data := User.PackageData;
    PS := Data.Credentials 
As IPasswordCredentials;
    
// Set password
    PS.Password := "Password";
    
// Save changes
    MS.Apply();
    
// Check in license
    Lic := Null;
End Sub;

After executing the example the temporary user account of the USERNAME user will be added that is available for use during two days.

See also:

IMetabaseSecurity