VBScript to Delete Specific User in AD

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<br/>

<pre class="prettyprint Option Explicit
Dim objOU, objDelUser
Dim objContainer, objRootLDAP, strObject, strDNSDomain
Dim FName, LName, userFullName
Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://RootDSE")
Set objContainer = GetObject("LDAP://CN=Users," & _
objRootLDAP.Get("defaultNamingContext"))


FName = "C"
LName = "D"

Try to Create User
DeleteUser FName, LName


FUNCTION DeleteUser(FName, LName)
FName = TRIM(FName)
LName = TRIM(LName)


userFullName = FName & " " & LName
Set objDelUser = objContainer.Delete("User", "cn=" & userFullName)
Set DeleteUser = objDelUser
END FUNCTION

wscript.quit
[/code]
I Created this VBScript and Im having a trouble on this.
when i execute the vbscript that i created on the AD the AD user will be Deleted but an error will POP - UP and here is the Error
Error: Object Required:objectContainer.Delete(...) <br/>
Code: 800A01A8 <br/>
Source: Microsoft VBScript runtime Error

What should I do to Fix this one?
Thanks
Paul.

View the full article
 

Similar threads

G
Replies
0
Views
101
Graham R Seach
G
C
Replies
0
Views
183
Csaba Árpádházy-Godó
C
J
Replies
0
Views
102
Jérôme MAISETTI
J
Back
Top