Directory Services

Authentication

In ADSI, credentials consisting of a user name and password allow system software to authenticate the identity of a user during the initial system login. Use IADsOpenDSObject::OpenDSObject or the helper function ADsOpenObject to establish a user's credentials for a directory service. If you do not use OpenDSObject, ADSI uses default credentials. When the system authenticates the user, the user is free to make requests for system resources, access to file shares, and file permissions, as supported by the underlying directory service security requirements.

The following Visual Basic code example shows how to use the OpenDSObject method to authenticate a user.

Dim MyNamespace As IADsOpenDSObject
Dim X
oUsername="MyUserName"
oPassword="MyPassword"

OnError GoTo CleanuUp
 
Set MyNamespace = GetObject("LDAP:")

' For authentication, pass a variable for the user name and password to be used for 
' authentication. It is recommended that you use the ADS_AUTHENTICATION_SECURE flag for 
' security reasons.
Set X = MyNamespace.OpenDSObject(DN, oUserName, oPassword, ADS_AUTHENTICATION_SECURE)
									
CleanUp:
	MsgBox ("An error has occurred.")
	Set MyNamespace = Nothing
	Set X = Nothing