_WearingPants Posted November 8, 2006 Share Posted November 8, 2006 Afternoon,We are using Windows PE in a decommissiong process:- tech boots to PE via F12 pxe- vbs script runs that gets Manufacturer, model and Serial number of machine using WMI- vbs script runs that looks up the serial number to computer name in an SMS 2003 SQL database- vbs script runs that writes this information to a seperate SQL database for reporting- vbs script runs that kicks off a gdisk32.exe DOD standard wipediskWhat we would like to do is before the HDD is wiped, delete the machine account from Active Directory for an end-to-end decomm process, with minimal tech involvement. Everything above is wokring fine, apart from the delete from AD bit.We have code that searches through AD (copied below) but it does not work in PE, it returns an error that the table does not exist (lack of credentials) when it goes to execute the command.By binding directly to the cmputer object/parent OU in AD we can delete it no worries but the problem is that the AD structure has branches of OU's all over the place and we need to be able to search.Any ideas?Rob.---------------------------------code---------------------------------Dim objRecordSetConst ADS_SCOPE_SUBTREE = 2Set objCommand = CreateObject("ADODB.Command")Set objConnection = CreateObject("ADODB.Connection")objConnection.Provider = "ADsDSOObject;USER ID=" & DOM & "\" & USERNAME & ";Password=" & PASSWORDobjConnection.Open "Active Directory Provider"objCommand.ActiveConnection = objConnectionstrBase = "<LDAP://dc=xxx,dc=xxx,dc=xxx>"strFilter = "(&(objectClass=computer)" & " (cn=" & StrCOMPUTERNAME & "))"strAttributes = "cn,distinguishedname"strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"objCommand.CommandText = strQueryobjCommand.Properties("Page Size") = 1000objCommand.Properties("Timeout") = 30objCommand.Properties("Cache Results") = FalseSet objRecordSet = objCommand.ExecuteobjRecordSet.MoveFirstDo Until objRecordSet.EOF StrNTName = objRecordSet.Fields("cn") If StrNTName = StrCOMPUTERNAME Then DN = objRecordSet.Fields("distinguishedname") End If objRecordSet.MoveNextLoopobjConnection.CloseSet objRootDSE = NothingSet objCommand = NothingSet objConnection = NothingSet objRecordSet = Nothing Link to comment Share on other sites More sharing options...
mats Posted November 8, 2006 Share Posted November 8, 2006 Have you added the adsi support files? Link to comment Share on other sites More sharing options...
_WearingPants Posted November 8, 2006 Author Share Posted November 8, 2006 yes. I can bind to an OU and list all users without any problems. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now