Jump to content

_WearingPants

Member
  • Posts

    2
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Australia

About _WearingPants

_WearingPants's Achievements

0

Reputation

  1. yes. I can bind to an OU and list all users without any problems.
  2. 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 wipedisk What 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 objRecordSet Const ADS_SCOPE_SUBTREE = 2 Set objCommand = CreateObject("ADODB.Command") Set objConnection = CreateObject("ADODB.Connection") objConnection.Provider = "ADsDSOObject;USER ID=" & DOM & "\" & USERNAME & ";Password=" & PASSWORD objConnection.Open "Active Directory Provider" objCommand.ActiveConnection = objConnection strBase = "<LDAP://dc=xxx,dc=xxx,dc=xxx>" strFilter = "(&(objectClass=computer)" & " (cn=" & StrCOMPUTERNAME & "))" strAttributes = "cn,distinguishedname" strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree" objCommand.CommandText = strQuery objCommand.Properties("Page Size") = 1000 objCommand.Properties("Timeout") = 30 objCommand.Properties("Cache Results") = False Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF StrNTName = objRecordSet.Fields("cn") If StrNTName = StrCOMPUTERNAME Then DN = objRecordSet.Fields("distinguishedname") End If objRecordSet.MoveNext Loop objConnection.Close Set objRootDSE = Nothing Set objCommand = Nothing Set objConnection = Nothing Set objRecordSet = Nothing
×
×
  • Create New...