SG77 Posted April 16, 2014 Share Posted April 16, 2014 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 More sharing options...
water Posted April 16, 2014 Share Posted April 16, 2014 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
SG77 Posted April 16, 2014 Author Share Posted April 16, 2014 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 More sharing options...
Solution water Posted April 16, 2014 Solution Share Posted April 16, 2014 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
SG77 Posted April 16, 2014 Author Share Posted April 16, 2014 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 More sharing options...
water Posted April 17, 2014 Share Posted April 17, 2014 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now