3.1.6.18 Prepare an LDAP Connection

This event MUST be generated with no arguments.

Return Values:

  • rADConnection: An ADCONNECTION_HANDLE ([MS-DTYP] section 2.2.2) that is connected to an Active Directory server and that is ready to perform LDAP operations. The value is undefined if rStatus is not DirectoryOperationResult.Success.

  • rStatus: A DirectoryOperationResult that indicates the result of this directory operation.

The algorithm MUST perform the following actions to process this event:

  • If the CachedLDAPConnection.Handle (section 3.1.1.6) ADM element attribute is not NULL:

    • Increment the value of the CachedLDAPConnection.RefCount ADM element attribute by 1.

    • Set rADConnection to the value of CachedLDAPConnection.Handle, and set rStatus to DirectoryOperationResult.Success.

    • Take no further action.

  • Let DirectoryServerConnection be a variable of type ADCONNECTION_HANDLE.

  • Perform the Initializing an ADConnection ([MS-ADTS] section 7.6.1.1) task, specifying the following parameters:

    • TaskInputTargetName = NULL

    • TaskInputPortNumber = 389

  • DirectoryServerConnection is set to the TaskReturnADConnection result returned by the task.

  • Perform the Setting an LDAP Option on an ADConnection ([MS-ADTS] section 7.6.1.2) task, specifying the following parameters:

    • TaskInputADConnection = DirectoryServerConnection

    • TaskInputOptionName = "LDAP_OPT_PROTOCOL_VERSION"

    • TaskInputOptionValue = 3

  • Perform the Establishing an ADConnection ([MS-ADTS] section 7.6.1.3) task, specifying the following parameters:

    • TaskInputADConnection = DirectoryServerConnection

  • If the TaskReturnStatus result is not success, as specified in [RFC2251] section 4.1.10, rStatus MUST be set to DirectoryOperationResult.GenericError, and processing MUST end.

  • Perform the Performing an LDAP Bind on an ADConnection ([MS-ADTS] section 7.6.1.4) task, specifying the following parameters:

    • TaskInputADConnection = DirectoryServerConnection

  • If the TaskReturnStatus result is not success, as specified in [RFC2251] section 4.1.10, rStatus MUST be set to DirectoryOperationResult.GenericError, and processing MUST end.

  • rADConnection MUST be set to DirectoryServerConnection, and rStatus MUST be set to DirectoryOperationResult.Success.

  • Set the CachedLDAPConnection.Handle ADM element attribute to the value of rADConnection, and set the CachedLDAPConnection.RefCount ADM element attribute to 1.