|
|
|
|
Alternate credentials can be passed to ADO by assigning values to properties of the ADO connection object. The syntax is shown below. In this example, I include several constants that I have seen used for the "ADSI Flag" value. I also show three different forms that can be used for the user name. ' ADS Authentication constants that can be used. Const ADS_SECURE_AUTHENTICATION = &H1 Const ADS_USE_ENCRYPTION = &H2 Const ADS_USE_SSL = &H2 Const ADS_USE_SIGNING = &H40 Const ADS_USE_SEALING = &H80 Const
ADS_USE_DELEGATION = &H100
' Specify credentials. ' Select one of the three possible forms for the user name. strUser = "cn=TestUser,ou=Sales,dc=MyDomain,dc=com" strUser = "TestUser@MyDomain.com" strUser = "MyDomain\TestUser" strPassword = "xyz12345"
' Create the ADO Connection object. Set adoConnection = CreateObject("ADODB.Connection") Or
ADS_SECURE_AUTHENTICATION The client computer must be joined to the domain. If the user is authenticated to the domain you can use serverless binding. However, if the user is logged in locally to the computer, and not authenticated to the domain, I find that you must use a server bind. You must specify the name of a Domain Controller. In the example below I assume the user is logged in locally. This VBScript program queries for all user objects in the domain and outputs the Distinguished Names. The name of a Domain Controller is hard coded, but the program uses the RootDSE object to retrieve the DNS name of the domain. The alternate credentials must also be used to connect to this object. You could instead hard code the DNS name of the domain. Option
Explicit
' Specify a server (Domain Controller). strServer =
"MyServer" ' Specify or
prompt for credentials. '
credentials. The value of strDNSDomain can
also be hard coded.
strUser, strPassword, _ ' Use
alternate credentials. Or
ADS_SECURE_AUTHENTICATION & strAttributes & ";subtree" If the user is authenticated to the domain, but lacks permission to run the query, you can use the more normal serverless binding. |
Send mail to
HilltopLab@RLMueller.Net with questions or comments about this web site.
|