|
sounddoc -> RE: How to query AD from WinPE 2.0 (5/28/2008 5:05:25 PM)
|
banging my head against the wall here!! I set those registry settings, and I no longer get the data source across domains error, but i'm back to the friggin 'table does not exist' error! no matter how I change my query I'm getting nowhere...the problem is that I don't know how I can test in PE, and within LTI where the script is failing. Now keep in mind the whole thing is in an HTA, within the on_load sub. If I deliberatrly muck with the query, like putting "foo" in the middle of it, I do get a syntax error, which I'm assuming at least means it's hitting the domain controller. For security purposes, let's assume I work at contoso, and my DC is called dc2. The script should take the first part of the hostname and match it to a samid in AD: sub window_OnLoad window.resizeTo 500,250 'set IE security oShell.regWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\1406", 0, "REG_DWORD" oShell.regWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1406", 0, "REG_DWORD" 'get the username portion of the hostname strComputer = oEnvironment.Item("COMPUTERNAME") fPartName = left(strComputer, instr(strComputer, "-") -1 ) 'search AD for matches Const ADS_SCOPE_SUBTREE = 2 Const ADS_SECURE_AUTHENTICATION = 1 Const ADS_SERVER_BIND = 200 set oConnection = CreateObject("ADODB.Connection") set oCommand = CreateObject("ADODB.Command") oConnection.Provider = "ADsDSOObject" oConnection.Properties("User ID") = oEnvironment.Item("DomainAdmin") & "@contoso.com" oConnection.Properties("Password") = oEnvironment.Item("DomainAdminPassword") oConnection.Properties("Encrypt Password") = True oConnection.Properties("ADSI Flag") = ADS_SERVER_BIND + ADS_SECURE_AUTHENTICATION oConnection.Open "Active Directory Provider" set oCommand.ActiveConnection = oConnection oCommand.CommandText = "SELECT * FROM 'LDAP://dc2.contoso.com/dc=contoso,dc=com'" & _ " WHERE objectCategory='User'"' AND samaccountname='" & fPartName & "*'" oCommand.Properties("Page Size") = 100 oCommand.Properties("SearchScope") = ADS_SCOPE_SUBTREE oCommand.Properties("Cache Results") = False set oRecordSet = oCommand.Execute oRecordSet.MoveFirst Do until oRecordSet.EOF set oOption = Document.CreateElement("OPTION") oOption.Text = oRecordSet.Fields("Name").Value oOption.Value = "CONTOSO\" & oRecordSet.Fields("samaccountname") usernameList.Add(oOption) oRecordSet.MoveNext loop oConnection.close() end sub At the very least I'm hoping for some sort of overflow error, or type mismatch which would at least mean that I'm getting data back. Anything besides 'Table does not exist" would be fantastic at this point. The script always fails at the line "set oRecordSet = oCommand.Execute". This is an LTI Deployment with ADO enabled in the boot image. adsldpc.dll is in X:\Windows\System32, so I know that AD support is enabled. Thanks again for the reply!
|
|
|
|