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 User

 Keywords: ADSI AD Delete User COM Container 

strContainer = ""       ; MODIFY TO FIT YOUR NEEDS
strName = "MyAdUser"    ; 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 User
ret = AskYesNo( "Delete User?", "Are you sure you want to delete [": strName :"]?")
If ret
   objContainer.Delete("user", "cn=" : strName )
EndIf

; Clean up
objContainer = 0
objRootDSE = 0

Article ID:   W18047
Filename:   ADSI COM Example - Delete a User.txt
File Created: 2012:12:06:08:50:00
Last Updated: 2012:12:06:08:50:00