Jump to content

Query AD with LDAP lookup in WinPE 3 [Solved]


mrbeatnik

Recommended Posts

Hi folks.

I am trying to query AD from Windows PE 3 (based on Windows 7).

My script works in Win 7 and XP, but I am aware there are issues with PE so need to modify the script.

I am aware that HTA cannot query with ADO, so I am just running a stand alone script.

I have added the Winpe-MDAC component to winpe (I also have HTA,WMI,WSH components as well).

I have also disabled the firewall, just in case...

Here is what I have (names changed to protect the innocent).


username = "myname"
DOMAIN = "myDCNAME/DC=subdomain,DC=domain,DC=com"

Set ADConn = CreateObject("ADODB.Connection")
ADConn.Provider = "ADSDSOObject"
ADConn.Properties("User ID") = "mydomain\myadreadableuser"
ADConn.Properties("Password") = "mypass"
AdConn.Properties("Encrypt Password") = true
ADConn.Open "ADs Provider"

query = "<LDAP://" & DOMAIN & ">;(&(objectclass=user)(sAMAccountName=" & username & "));distinguishedName;subtree"
Set ADrs = ADConn.Execute(cstr(query))
IF NOT ADrs.EOF Then
WScript.Echo ADrs("distinguishedName")
End If

So I get the error 80040E37 on the execution of the code.

Any suggestions why this wont work?

How can I check that I have all needed components?

[EDIT REASON : Added Solved to title!]

Edited by mrbeatnik
Link to comment
Share on other sites


Since it's WinPE you need to specify a domain controller to connect to. You also need to add the ADSI components as well. I have written ADSI plugins for WinPE 3.0 (x86 and x64) that you can download from this link

ADSI Plugin for Windows PE 3.0 (x86 and x64)

http://www.deployvista.com/Home/tabid/36/EntryID/127/language/sv-SE/Default.aspx

There is a sample script in the Plugin that will show you a working connection.

Link to comment
Share on other sites

Since it's WinPE you need to specify a domain controller to connect to. You also need to add the ADSI components as well. I have written ADSI plugins for WinPE 3.0 (x86 and x64) that you can download from this link

ADSI Plugin for Windows PE 3.0 (x86 and x64)

http://www.deployvista.com/Home/tabid/36/EntryID/127/language/sv-SE/Default.aspx

There is a sample script in the Plugin that will show you a working connection.

:thumbup

Perfect.

I was just missing the DLLs.

Of course I would just assume the MDAC package would supply them...

Thanks for reference. The INF file was really handy for the registration of the files.

Thanks again!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...