Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Query AD with LDAP lookup in WinPE 3 [Solved]

- - - - -

  • Please log in to reply
2 replies to this topic

#1
mrbeatnik

mrbeatnik

    Newbie

  • Member
  • 33 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, 27 May 2010 - 08:51 AM.



How to remove advertisement from MSFN

#2
arwidmark

arwidmark

    Member

  • Member
  • PipPip
  • 105 posts
  • OS:none specified
  • Country: Country Flag
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.deployvis...SE/Default.aspx

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

Johan Arwidmark
Microsoft MVP - Setup / Deployment

#3
mrbeatnik

mrbeatnik

    Newbie

  • Member
  • 33 posts

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.deployvis...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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN