Platform SDK: Active Directory, ADSI, and Directory Services |
[Visual Basic]
If you are a Visual Basic developer, you must use IADsOpenDSObject as shown in the following example:
Dim openDS As IADsOpenDSObject Dim usr As IADsUser Set openDS = GetObject("LDAP:") openDS.OpenDSObject("LDAP://CN=Bob,DC=Microsoft,DC=com", "Administrator", "password", ADS_SECURE_AUTHENTICATION)
[C/C++]
If you are a C/C++ developer, you should use ADsOpenObject as shown in the following example:
IADs *pObject; HRESULT hr; hr = ADsOpenObject(L"LDAP://CN=Bob,DC=Microsoft,DC=com", L"Administrator", L"password", ADS_SECURE_AUTHENTICATION, IID_IADs, (void**)&pObject);
To bind as the current user, pass NULL in both the user and password parameters.
hr = ADsOpenObject(L"LDAP://CN=Bob,DC=Microsoft,DC=com", NULL, NULL, ADS_SECURE_AUTHENTICATION, IID_IADs, (void**)&pObject);