Re: ADO with alternate credentials
- From: "Steve" <Steve@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 3 Nov 2005 06:08:02 -0800
I was able to use the format below as long as the system is joined to the AD
domain I'm querying. It still will not work if the system is not joined to
the domain. It appears that AD will not answer to an 'anonymous' system even
with valid credentials. I tried turning of 'encrypt password' but still no
go.
Steve
Set objADOConnection = CreateObject("ADODB.Connection")
objADOConnection.Provider = "ADsDSOObject"
objADOConnection.Properties("User ID") = txtUserID
objADOConnection.Properties("Password") = txtPassword
objADOConnection.Properties("Encrypt Password") = True
objADOConnection.Open "DS Query", txtUserID, txtPassword
"/\\/\\o\\/\\/" wrote:
> you can set the username and password on an ADO connection like this :
>
> objADOConnection.name = "usr"
> objADOConnection.Password = "psw"
>
> I can not test if it works with the ADsDSOObject provider,
> till friday.
>
> hope this helps.
>
> gr /\/\o\/\/
>
> 3
>
> Steve wrote:
> > I'm trying to use ADO to enumerate the OU's in AD using another
> > userid/password. A pice of the script is below. ANyone know how to use a
> > different userid?
> >
> > Thanks,
> > Steve
> >
> > 'parse domain name and set command vars
> > strADsPath = "dc=" & Replace(txtDomain, ".", ";dc=")
> > strBase = "<LDAP://" & strADsPath & ">"
> > strFilter = "(objectCategory=ORGANIZATIONALUNIT)"
> > strAttributes = "ou,distinguishedName"
> > strScope = "subtree"
> >
> > ' Create ADO connection and command
> > Set objADOConnection = CreateObject("ADODB.Connection")
> > objADOConnection.Open "Provider=ADsDSOObject;"
> > Set objADOCommand = CreateObject("ADODB.Command")
> > objADOCommand.ActiveConnection = objADOConnection
> >
> > ' Create the command string using the four parts
> > objADOCommand.CommandText = strBase & ";" & strFilter & ";" & strAttributes
> > & ";" & strScope
> >
> > ' Set the properties of the recordset
> > objADOCommand.Properties("Page Size") = 2000
> > objADOCommand.Properties("Size Limit") = 20000
> >
> > ' Execute the query for the user in the directory
> > Set objADORecordset = objADOCommand.Execute
> >
> >
>
.
- References:
- Re: ADO with alternate credentials
- From: /\\/\\o\\/\\/
- Re: ADO with alternate credentials
- Prev by Date: Re: [MSH] How to Create threads
- Next by Date: Copy a file
- Previous by thread: Re: ADO with alternate credentials
- Next by thread: Re: Running a script as a Windows service
- Index(es):
Relevant Pages
|