Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Error in script to delete AD account - Passing variable to strUser

Reply
 
Old 02-11-2009   #1 (permalink)
nlldavies


 
 

Error in script to delete AD account - Passing variable to strUser

Hi all. I'm looking for some help on the following code. It's part of a
larger scriopt that basically takes a username from a list containing
multiple username, processes it and then delete's the user's account from
Active Directory. The user's username is passed to the variable "ip".

I've had the script working using a input box to take the username, but I'm
struggling when trying to pass the username via another vairable.

The error I get is a syntax error on the 6th line in:


strUserName = ip

' Call function to delete user
DeleteUser strUserName,strDomain

sub DeleteUser(byval strUserName,strDomain)

userDN = GetUserDN(strUserName,strDomain)
set objUser = getObject("LDAP://" & userDN)
set objContainer = getobject(objUser.Parent)
objContainer.Delete "user","cn=" & objUser.cn

end sub

Function GetUserDN(byval strUserName,byval strDomain)

Set objTrans = CreateObject("NameTranslate")
objTrans.Init 1, strDomain
objTrans.Set 3, strDomain & "\" & strUserName
strUserDN = objTrans.Get(1)
GetUserDN = strUserDN

end function

Any help greatly appreciated.

N

My System SpecsSystem Spec
Old 02-11-2009   #2 (permalink)
nlldavies


 
 

RE: Error in script to delete AD account - Passing variable to strUser

Sorry for multiple posts, website said there was an error posting so I
re-submitted.

N

"nlldavies" wrote:
Quote:

> Hi all. I'm looking for some help on the following code. It's part of a
> larger scriopt that basically takes a username from a list containing
> multiple username, processes it and then delete's the user's account from
> Active Directory. The user's username is passed to the variable "ip".
>
> I've had the script working using a input box to take the username, but I'm
> struggling when trying to pass the username via another vairable.
>
> The error I get is a syntax error on the 6th line in:
>
>
> strUserName = ip
>
> ' Call function to delete user
> DeleteUser strUserName,strDomain
>
> sub DeleteUser(byval strUserName,strDomain)
>
> userDN = GetUserDN(strUserName,strDomain)
> set objUser = getObject("LDAP://" & userDN)
> set objContainer = getobject(objUser.Parent)
> objContainer.Delete "user","cn=" & objUser.cn
>
> end sub
>
> Function GetUserDN(byval strUserName,byval strDomain)
>
> Set objTrans = CreateObject("NameTranslate")
> objTrans.Init 1, strDomain
> objTrans.Set 3, strDomain & "\" & strUserName
> strUserDN = objTrans.Get(1)
> GetUserDN = strUserDN
>
> end function
>
> Any help greatly appreciated.
>
> N
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Passing parameters to a PS script PowerShell
problem passing args to script 'There is no script engine for file extenstion' VB Script
Passing parameters to a cmdlet in a variable PowerShell
Passing dynamic number of parameters to a function as a variable PowerShell
passing variable by reference PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46