Re: CreateADUSer function
- From: "Richard Mueller [MVP]" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 13 Jan 2007 14:04:57 -0600
I assume this is a typo:
Set objUser = objou.Create("User","CN=Lastname,\ Firstname" )
This would raise an error, but in your first posting it looked correct.
AccountDisabled is still spelled wrong.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--
"Ralph Karam" <RalphKaram@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:53AFF232-41EC-45F3-9E10-BC14C875E520@xxxxxxxxxxxxxxxx
Thanks Al,code
I tried the method you suggeted as I understood it and the process still
fails. I'll pos the whole script if you still think its necessary.
regarding the code that sets the variable I'm confident they work properly
because I have functions that check to see if the Displayname, mail, and
samaccountname already exist and they work very well
*****************
code snip
response1 = MsgBox ("Do you want to run in Create Users
mode?",vbyesno,"Create users?")
If response1 = vbyes then
Call CreateUser
End If
Function CreateUser
Set objou = GetObject("LDAP:\\OU=Users,OU=NJ,DC=testdomain,DC=local" )
Set objUser = objou.Create("User","CN=Lastname,\ Firstname" )
objuser.sAMAccountname = "FLastname"
objuser.SetInfo
objuser.givenName = "Firstname"
objuser.sn = "Lastname"
objuser.displayName = "LastName, FirstName"
objuser.mail = "Firstname.Lastname@xxxxxxxxxxxxxx"
objuser.SetPassword "P@55word"
objUser.SetInfo
objUser.AcountDisabled = False
objUser.SetInfo
End Function
"Al Dunbar [MS-MVP]" wrote:
It is hard to say where the problem lies, as you have not shared the
intothat conditionally calls this function or the code that sets the global
variables it uses.
To see if the problem is in the function itself, I'd suggest pasting it
anda short test script that sets reasonable values for stracctname and etc.
errorsthen calls the function unconditionally. If that still fails and no
sureare flagged, add code to the function to display the variables to make
thanyou are not, for example, spelling them differently in the main program.
As a point of style and maintainability, a function like this makes much
more sense when the values it needs are passed as parameters, rather
I'vethrough global variables.
/Al
"Ralph Karam" <RalphKaram@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:63C51000-37D3-4D18-B37B-37D02A21A6AB@xxxxxxxxxxxxxxxx
I'm unable to find out why my user accounts are not being created
usergot
an If then statement higher that calls this function if I want the
ancreated. i know none of the users exist because I'm testing against
strDCRoot)empty
domain.
'**********************************************
Function CreateUser
Set objou = GetObject("LDAP:\\OU=Users,OU=" & strstate & "," &
strfname)Set objUser = objou.Create("User","CN= " & strlname & "\, " &
objuser.sAMAccountname = stracctname
objuser.SetInfo
objuser.givenName = strfname
objuser.sn = strlname
objuser.displayName = strdisplayname
objuser.mail = strmail
objuser.SetPassword strPWD
objUser.SetInfo
objUser.AcountDisabled = False
objUser.SetInfo
' WScript.Echo "Account: " & strdisplayname & " created successfully"
End Function
'*************************************
Ralph
.
- Follow-Ups:
- Re: CreateADUSer function
- From: Ralph Karam
- Re: CreateADUSer function
- References:
- Re: CreateADUSer function
- From: Al Dunbar [MS-MVP]
- Re: CreateADUSer function
- From: Ralph Karam
- Re: CreateADUSer function
- Prev by Date: VBS Class error...
- Next by Date: Re: VBS Class error...
- Previous by thread: Re: CreateADUSer function
- Next by thread: Re: CreateADUSer function
- Index(es):