Re: CreateADUSer function



Thanks Al,

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 code
that 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 into
a short test script that sets reasonable values for stracctname and etc. and
then calls the function unconditionally. If that still fails and no errors
are flagged, add code to the function to display the variables to make sure
you 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 than
through 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 I've
got
an If then statement higher that calls this function if I want the user
created. i know none of the users exist because I'm testing against an
empty
domain.

'**********************************************
Function CreateUser
Set objou = GetObject("LDAP:\\OU=Users,OU=" & strstate & "," & strDCRoot)
Set objUser = objou.Create("User","CN= " & strlname & "\, " & strfname)
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



.



Relevant Pages

  • Re: How to set up a global variable in a sub-routine?
    ... the 'global variables' are more like constants ... ... single script, I need a way to tell it only once where the file is and ... So, if you construct a loop with a loop variable, you ... >programmers avoid global variables completely. ...
    (perl.beginners)
  • Re: Setting sql result to global variable?
    ... some dummy SQL to set-up the parameter mapping, then the real SQL will get ... I also suggest you use SET NOCOUNT ON at the top of your script, ... Global Variables and Stored Procedure Parameters ... > Set objPkg = DTSGlobalVariables.Parent ...
    (microsoft.public.sqlserver.dts)
  • Global Variables Between Parent and Child Documents (Windows)
    ... Heavily scripted HTML document #1, very application-like, must include the ... function to name a "callback" function, and within its own script block, ... the filesystem/file selection interface as dynamically updated HTML- ... I am seeing this as a some sort of conflict of global variables between ...
    (comp.lang.javascript)
  • Re: javaldx failed.
    ... mozilla start from default fails, ... error message. ... console in the icewm window but I resolved this for the console window ... get script ...
    (Debian-User)
  • Re: newbie needs help with form validation
    ... When using radio buttons, it is suggested that one be checked by default. ... it is impossible to return to the 'none checked' state without either resetting the form or using script. ... Only create global variables when absolutely necessary, ... you should keep such variables local with var: ...
    (comp.lang.javascript)