Jump to content

Error called with wrong number of args


SG77
 Share

Go to solution Solved by water,

Recommended Posts

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 & ".")
    

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
Share on other sites

  • Solution

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...