Platform SDK: Active Directory, ADSI, and Directory Services |
The following code fragment binds to an object with the name Bob in the Microsoft.com. The example uses secure authentication, but it does not specify any credentials, so it binds using the default credentials of the caller's security context.
Dim np as IADsOpenDSObject Dim myUser as IADs Set np = GetObject("LDAP:") Set myUser = np.OpenDSObject("LDAP://CN=Bob,DC=Microsoft,DC=com",vbNullString,vbNullString, ADS_SECURE_AUTHENTICATION)
IADs *pObject; HRESULT hr; hr = ADsOpenObject(L"LDAP://CN=Bob,DC=Microsoft,DC=com", NULL, NULL, ADS_SECURE_AUTHENTICATION, IID_IADs, (void**) &pObject);
If you set the fourth parameter to zero rather than specifying an authentication flag, ADSI performs a simple bind, which is sent as clear text. If you specify a user account and password without specifying authentication flags, they go over the network as clear text, which is a breach of security. Do not specify a user and password without also specifying authentication flags.