WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI LDAP CDO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ADSI COM Example - Delete a Computer

 Keywords: ADSI AD Delete Computer Object COM Container 

strContainer = ""       ; MODIFY TO FIT YOUR NEEDS
strName = "MyAdComuter"    ; MODIFY TO FIT YOUR NEEDS

; Obtain Root DSE
objRootDSE = ObjectGet("LDAP://rootDSE")

; Get Container Object
If strContainer == ""
  ldappath = "LDAP://" : objRootDSE.Get("defaultNamingContext")
  objContainer = ObjectGet(ldappath)
Else
  ldappath =  "LDAP://" : strContainer : "," : objRootDSE.Get("defaultNamingContext")
  objContainer = ObjectGet(ldappath)
EndIf

; Delete Computer
ret = AskYesNo( "Delete Computer?", "Are you sure you want to delete [": strName :"]?")
If ret
   objContainer.Delete("user", "cn=" : strName )
EndIf

; Clean up
objContainer = 0
objRootDSE = 0

Article ID:   W18046
Filename:   ADSI COM Example - Delete a Computer.txt
File Created: 2012:12:06:08:52:06
Last Updated: 2012:12:06:08:52:06