Sign in to follow this  
Followers 0
SG77

Error called with wrong number of args

6 posts in this topic

Hi

I am in the process of learning Autoit and scripting.  I am getting the following message on this line when I run a Syntax Check and am not sure what I am missing.  If anyone could help I would be very grateful.

 _AD_CreateUser("OU=" & $UsrOU & ",OU=Student,OU=Users,OU=xxxx,DC=xxxxxxx,DC=xxxxxx", $UsrSAM, $UsrFName, $UsrULName, "Class_of" & $UsrOU & ".")
    

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

Function _AD_CreateUser expects 3 parameters: $sOU, $sUser and $sCN.

You are passing 5 parameters.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you Water .. as you can tell I am still green around the edges... if the following is my parameters how can I get the _AD_CreateUser to function?

 $UsrFName = "Test"
 $UsrOU = "2014"
 $UsrSAM = "1111111111"
 $UsrULName = "Account"

(Will these still work or do you have to use $sOU, $sUser and $sCN?)

 _AD_CreateUser("OU=" & $UsrOU & ",OU=Student,OU=Users,OU=xxxx,DC=xxxxx,DC=xxxxx", $UsrSAM, ??)

I am working off a previous script so trying not to change the defined names too much.

Thank you again for any suggestions and assistance.

Share this post


Link to post
Share on other sites

This should work.

Parameter 1 is the OU (Organizational Unit) where the user is being created. Parameter 3 is the CN (Container) for the user in the OU. Parameter 2 is being used for the SamAccountName and the User principle Name.

$iReturnValue = _AD_CreateUser("OU=" & $UsrOU & ",OU=Student,OU=Users,OU=xxxx,DC=xxxxx,DC=xxxxx", $UsrSAM, $UsrULName & " " & $UsrFName)

On error macro @error is set to <> 0. On success $iReturnValue should be 1.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you again Water

I see why you are a MVPs

That has worked for me in a test OU but for some reason does not create a new user in my script.  I will continue to research and work on it but at least now I am not getting any errors when I do a syntax check.

Little Steps .. but enjoying the challenge

Share this post


Link to post
Share on other sites

Maybe a permission problem?

Add

_AD_ErrorNotify(2)

at the top of your script to get maximum error information.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0