ISecuritySubjectsSearch.DomainCredentials

Fore Syntax

DomainCredentials: IDomainCredentials;

Fore.NET Syntax

DomainCredentials: Prognoz.Platform.Interop.Metabase.IDomainCredentials;

Description

The DomainCredentials property determines the credentials, under which domain authentication is performed on search.

Fore Example

To execute the example, add a link to the Metabase system assembly.

Sub FindSubject;
Var
    MB: IMetabase;
    Pack: ISecurityPackage;
    DomainCreds: IDomainCredentials;
    Search: ISecuritySubjectsSearch;
    Subjects: ISecuritySubjects;
    Subject: ISecuritySubject;
Begin
    MB := MetabaseClass.Active;
    Search := MB.Security.NewSubjectsSearch;
    Search.NameCriteria := "TestDomain\*";
    Search.SubjectCriteria(SecuritySubjectType.User) := True;
    Search.SubjectCriteria(SecuritySubjectType.Group) := True;
    Search.AreaIncludeDB := False;
    Search.AreaIncludeNT := True;
    //Settings for search in domain
    Pack := New StandardSecurityPackage.Create;
    //Use credentials of the current user authenticated in domain
    DomainCreds := Pack.CreateCredentials(AuthenticationMode.Domain) As IDomainCredentials;
    DomainCreds.LogonAsCurrentUser := True;
    Search.DomainSelectCriteria := DomainSelectType.SpecifiedDomain;
    Search.ProtocolSelectCriteria := ProtocolSelectType.GC;
    //Search
    Search.ExecuteSearch;
    Subjects := Search.Subjects;
    If Subjects.Count > 0 Then
        For Each Subject In Subjects Do
            Debug.WriteLine("Distinguished Name: " + Subject.DistinguishedName);
            If Subject.Type = SecuritySubjectType.User Then
                Debug.WriteLine("Domain User Name: " + Subject.UserPrincipalName);
            End If;
        End For;
    End If;
End Sub FindSubject;

On executing the example all security subjects registered in the TestDomain domain are searched. Different names for the found subjects are displayed in the development environment console. Domain names are also displayed for domain users.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Pack: ISecurityPackage = New StandardSecurityPackageClass();
    DomainCreds: IDomainCredentials;
    Search: ISecuritySubjectsSearch;
    Subjects: ISecuritySubjects;
    Subject: ISecuritySubject;
Begin
    MB := Params.Metabase;
    Search := MB.Security.NewSubjectsSearch();
    Search.NameCriteria := "TestDomain\*";
    Search.SubjectCriteria[SecuritySubjectType.sstUser] := True;
    Search.SubjectCriteria[SecuritySubjectType.sstGroup] := True;
    Search.AreaIncludeDB := False;
    Search.AreaIncludeNT := True;
    //Settings for search in domain
    //Use credentials of the current user authenticated in domain
    DomainCreds := Pack.CreateCredentials(AuthenticationMode.amDomain) As IDomainCredentials;
    DomainCreds.LogonAsCurrentUser := True;
    Search.DomainSelectCriteria := DomainSelectType.dstSpecifiedDomain;
    Search.ProtocolSelectCriteria := ProtocolSelectType.pstGC;
    //Search
    Search.ExecuteSearch();
    Subjects := Search.Subjects;
    If Subjects.Count > 0 Then
        For Each Subject In Subjects Do
            System.Diagnostics.Debug.WriteLine("Distinguished Name: " + Subject.DistinguishedName);
            If Subject.Type = SecuritySubjectType.sstUser Then
                System.Diagnostics.Debug.WriteLine("Domain User Name: " + Subject.UserPrincipalName);
            End If;
        End For;
    End If;
End Sub;

See also:

ISecuritySubjectsSearch