ItemSetup(Index: Integer): IMetabaseSecuritySubjectUpdateSetup;
Index. User index in update list.
The ItemSetup property returns security subject update options.
Executing the example requires that the security manager contains the DOMAIN\USER domain user.
Add a link to the Metabase system assembly.
Sub UserProc;
Var
MB: IMetabase;
MS: IMetabaseSecurity;
Session: ILogonSession;
User: IMetabaseUser;
UsUpdate: IMetabaseUsersUpdate;
UsUpdateSec: IMetabaseSecuritySubjectUpdateSetup;
Lic: Object;
UserName: String;
Begin
MB := MetabaseClass.Active;
// Get information about the current repository session
Session := MB.LogonSession;
// Specify credentials of the current user if he has administrator permissions on DBMS level
Session.Credentials("$SYSTEM", True) := Session.LogonCredentials;
// Get license to work with the security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
MS := MB.Security;
// Create a user update object
UsUpdate := MS.CreateUsersUpdate;
// Get domain user who must be synchronized with LDAP
UserName := "DOMAIN\USER";
User := MS.ResolveName(UserName) As IMetabaseUser;
If User <> Null Then
If User.IsNT Then
// Display domain user attributes before synchronization
Debug.WriteLine("Domain user attributes before synchronization with LDAP:");
Debug.WriteLine("Name " + User.Name + ":");
Debug.WriteLine("SID: " + User.Sid.AsString);
Debug.WriteLine("UPN: " + User.UserPrincipalName);
Debug.WriteLine("Description: " + User.Description);
Debug.WriteLine("");
// Add a domain user to update
UsUpdate.Add(User);
// Set update method - synchronization of attributes with LDAP
UsUpdateSec := UsUpdate.ItemSetup(0);
UsUpdateSec.UpdateType := MetabaseSecuritySubjectUpdateType.LDAPSync;
// Update information about domain user and synchronize attributes
MS.UpdateUsers(UsUpdate);
// Display domain user attributes after synchronization
Debug.WriteLine("Domain user attributes after synchronization with LDAP:");
Debug.WriteLine("Name: " + User.Name);
Debug.WriteLine("SID: " + User.Sid.AsString);
Debug.WriteLine("UPN: " + User.UserPrincipalName);
Debug.WriteLine("Description: " + User.Description);
Debug.WriteLine("");
// Save changes
MS.Apply;
End If;
Else
Debug.WriteLine("The " + UserName + " user is not found in the security manager");
End If;
// Check in license
Lic := Null;
End Sub UserProc;
After executing the example, domain user attributes are synchronized with LDAP directory attributes. The console displays information about user attribute values before and after synchronization:
Domain user attributes before synchronization with LDAP:
Name: DOMAIN\USER
SID: S-1-5-21-2798585636-1410933581-2846741107-2611
UPN: USER@DOMAIN.REALM
Description: User 1
Domain user attributes after synchronization with LDAP:
Name: DOMAIN\CHANGED_USER_NAME
SID: S-1-5-21-2798585636-1410933581-2846741107-2611
UPN: CHANGED_USER_NAME@DOMAIN.REALM
Description: User 1
If the DOMAIN\USER user is not found in the security manager, the console displays the corresponding message.
When attributes are being synchronized, domain users are renamed on DBMS level. Renaming of domain users is available only in PostgreSQL DBMS if the following conditions are satisfied:
In the LDAP directory the value of the attribute mapped with user name (value of the Name attribute) has changed in the settings.xml file.
The domain user is not connected from server.
Built-in authorization is not used.
See also: