Jump to content

Active Directory, Create User


bcdietz
 Share

Recommended Posts

I'm trying to put a gui interface for creating users at our company. Most of it is due to Water's most execlent functions.

Here's the code:

#include <AD.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#Region ### START Koda GUI section ### Form=C:Program Files (x86)AutoIt3FormsNewUser.kxf
Global $Form1_1 = GUICreate("NewUser", 579, 665, 221, 127)
Global $fname = GUICtrlCreateInput("", 16, 40, 129, 21)
Global $minitial = GUICtrlCreateInput("", 168, 40, 57, 21)
GUICtrlSetLimit($minitial, 1)
Global $lname = GUICtrlCreateInput("", 248, 40, 145, 21)
Global $Label1 = GUICtrlCreateLabel("First Name", 16, 16, 54, 17)
Global $Label2 = GUICtrlCreateLabel("Initials", 168, 16, 33, 17)
Global $Label3 = GUICtrlCreateLabel("Last Name", 248, 16, 55, 17)
Global $name = GUICtrlCreateInput("", 16, 96, 377, 21)
Global $logon = GUICtrlCreateInput("", 16, 152, 129, 21)
Global $Label4 = GUICtrlCreateLabel("Name", 16, 72, 32, 17)
Global $Label5 = GUICtrlCreateLabel("User Logon Name", 16, 128, 90, 17)
Global $Label6 = GUICtrlCreateLabel("Password", 208, 128, 50, 17)
Global $password = GUICtrlCreateInput("Password01", 208, 152, 185, 21)
Global $Label10 = GUICtrlCreateLabel("User OU", 16, 184, 45, 17)
Global $ListOU = GUICtrlCreateCombo("", 16, 208, 377, 25)
Global $valid = GUICtrlCreateLabel("Valid", 120, 128, 27, 17)
GUICtrlSetColor($valid, 0x00FF00)
GUICtrlSetState($valid, $GUI_HIDE)
Global $invalid = GUICtrlCreateLabel("Invalid", 120, 128, 35, 17)
GUICtrlSetColor($invalid, 0xFF0000)
GUICtrlSetState($invalid, $GUI_HIDE)
Global $Label8 = GUICtrlCreateLabel("Employee Number", 16, 247, 90, 17)
Global $c_attribute1 = GUICtrlCreateInput("", 16, 271, 113, 21)
Global $c_attribute9 = GUICtrlCreateCheckbox("xxxx", 188, 263, 113, 33)
GUICtrlSetState($c_attribute9, $GUI_CHECKED)
Global $date = GUICtrlCreateDate("2012/01/26 15:54:4", 320, 272, 209, 25)
GUICtrlSetState($date, $GUI_HIDE)
Global $Label7 = GUICtrlCreateLabel("Description", 16, 304, 57, 17)
Global $Description = GUICtrlCreateInput("", 16, 336, 385, 21)
Global $Label9 = GUICtrlCreateLabel("Office", 16, 376, 32, 17)
Global $office = GUICtrlCreateInput("", 16, 400, 129, 21)
Global $Label11 = GUICtrlCreateLabel("Telephone", 160, 376, 55, 17)
Global $phone = GUICtrlCreateInput("", 160, 400, 129, 21)
Global $Label12 = GUICtrlCreateLabel("Web page", 304, 376, 54, 17)
Global $web = GUICtrlCreateInput("[url="http://www.xxxx.com"]http://www.xxxx.com[/url]", 304, 400, 153, 21)
Global $po = GUICtrlCreateInput("xxxx", 16, 456, 57, 21)
Global $city = GUICtrlCreateInput("xxxx", 80, 456, 81, 21)
Global $state = GUICtrlCreateInput("xx", 168, 456, 57, 21)
Global $zip = GUICtrlCreateInput("xxxx", 232, 456, 49, 21)
Global $Label13 = GUICtrlCreateLabel("P.O. Box, City, State, Zip", 16, 432, 121, 17)
Global $btn_create = GUICtrlCreateButton("Create", 440, 608, 97, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$iAD_Debug = 2
$rc = _AD_Open()
Global $sOU
Global $adOU = _AD_GetObjectsInOU("OU=USERS,OU=xxx,DC=xxxx,DC=com","(objectCategory=organizationalUnit)",1,"name,distinguishedName","name")
;_ArrayDisplay($adOU, "Active Directory Functions - Example 1 - Objects in OU '" & $adOU & "'")
 For $iCount = 1 To $adOU[0][0]
     If $iCount = 1 Then
       $sOU = $adOU[$iCount][0]
       $sOU = $adOU[$iCount][0]
     Else
       $sOU = $sOU & "|" & $adOU[$iCount][0]
    EndIf
 Next
 GUICtrlSetData($ListOU,$sOU)
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  
  Case $c_attribute1
  Case $c_attribute9
   Global $sc_attribute9 = GUICtrlRead($c_attribute9)
   if $sc_attribute9 = $GUI_UNCHECKED Then
   GUICtrlSetState($date, $GUI_SHOW)
   else
   GUICtrlSetState($date, $GUI_HIDE)
   endif
  Case $fname
  Case $minitial
  Case $lname
   Global $sfname = GUICtrlRead($fname)
   Global $slname = GUICtrlRead($lname)
   Global $sminitial = GUICtrlRead($minitial)
   GuiCtrlSetData($name,$slname & ", " & $sfname & " " & $sminitial)
   Global $sfl = StringRegExp($sfname,'AD',1)
   GuiCtrlSetData($logon, StringLower($sfl[0] & $sminitial & $slname))
   Global $slogon = GUICtrlRead($logon)
   $aUser = _AD_SamAccountNameToFQDN($slogon)
   if $aUser = "" Then
   GUICtrlSetState($valid, $GUI_SHOW)
   GUICtrlSetState($invalid, $GUI_HIDE)
   else
   GUICtrlSetState($invalid, $GUI_SHOW)
   GUICtrlSetState($valid, $GUI_HIDE)
   endif
  Case $name
   
  Case $logon
   Global $slogon = GUICtrlRead($logon)
   $aUser = _AD_SamAccountNameToFQDN($slogon)
   if $aUser = "" Then
   GUICtrlSetState($valid, $GUI_SHOW)
   GUICtrlSetState($invalid, $GUI_HIDE)
   else
   GUICtrlSetState($invalid, $GUI_SHOW)
   GUICtrlSetState($valid, $GUI_HIDE)
   endif
   
  Case $password
  Case $btn_create
   $sfname = GUICtrlRead($fname)
   $sminitial = GUICtrlRead($minitial)
   $slname = GUICtrlRead($lname)
   
   $slogon = GUICtrlRead($logon)
   $sname = GUICtrlRead($name)  
   $sListOU = GUICtrlRead($ListOU)
   $suOUnum = _ArraySearch($adOU,$sListOU,0,0,0,0,1,0)
   $suOU = $adOU[$suOUnum][1]
   $sEmpNum = GUICtrlRead($c_attribute1)
   $sEmployee = GUICtrlRead($c_attribute9)
   $sdescription = GUICtrlRead($description)
   $soffice = GUICtrlRead($office)
   $sphone = GUICtrlRead($phone)
   $sweb = GUICtrlRead($web)
   $spo = GUICtrlRead($po)
   $scity = GUICtrlRead($city)
   $sstate = GUICtrlRead($state)
   $szip = GUICtrlRead($zip)

   ExitLoop
  Case $ListOU
 EndSwitch
WEnd
Global $iValue = _AD_CreateUser($suOU, $slogon, _AD_FixSpecialChars($sname))
  ; If $iValue = 1  Then
 ; MsgBox(64, "Active Directory Functions - Example 1", "User '" & $slogon & "' in OU '" & $suOU & "' successfully created")
; ElseIf @error = 1 Then
 ; MsgBox(64, "Active Directory Functions - Example 1", "User '" & $slogon & "' already exists")
; ElseIf @error = 2 Then
 ; MsgBox(64, "Active Directory Functions - Example 1", "OU '" & $suOU & "' does not exist")
; ElseIf @error = 3 Then
 ; MsgBox(64, "Active Directory Functions - Example 1", "Value for CN (e.g. Lastname Firstname) is missing")
; ElseIf @error = 4 Then
 ; MsgBox(64, "Active Directory Functions - Example 1", "Value for $sAD_User is missing")
; Else
 ; MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & " - "  & $suOU & " - " & $slogon & " - " & $sname & "' from Active Directory")
; EndIf
;Sleep(250)
$aUser = _AD_SamAccountNameToFQDN($slogon)
_AD_SetPasswordExpire($aUser,0)
_AD_ModifyAttribute($aUser, "givenName", $sfname)
_AD_ModifyAttribute($aUser, "initials", $sminitial)
_AD_ModifyAttribute($aUser, "displayName", $sname)
_AD_ModifyAttribute($aUser, "sn", $slname)
_AD_ModifyAttribute($aUser, "description", $sDescription)
_AD_ModifyAttribute($aUser, "extensionAttribute1", $sEmpNum)
_AD_ModifyAttribute($aUser, "extensionAttribute9", $sEmployee)
_AD_ModifyAttribute($aUser, "physicalDeliveryOfficeName", $soffice)
_AD_ModifyAttribute($aUser, "telephoneNumber", $sphone)
_AD_ModifyAttribute($aUser, "wWWHomePage", $sweb)
_AD_ModifyAttribute($aUser, "postOfficeBox", $spo)
_AD_ModifyAttribute($aUser, "l", $scity)
_AD_ModifyAttribute($aUser, "st", $sstate)
_AD_ModifyAttribute($aUser, "postalCode", $szip)
_AD_ModifyAttribute($aUser, "co", "United States")
_AD_ModifyAttribute($aUser, "info", "Account created on " & @MON & "/" & @MDAY & "/" & @YEAR & " by " & @UserName )
sleep(500)
 
$eMBX = "FifthSG-DB"
$eis = "Fifth Storage Group"
$esv = "EXCH-MB1"
Global $iValue = _AD_CreateMailbox($aUser,$eMBX,$eis,$esv)
 If $iValue = 1 and $debug = 1 Then
 MsgBox(64, "Active Directory Functions - Example 1", "Mailbox for User '" & $aUser & "' successfully created")
ElseIf @error = 1 Then
 MsgBox(64, "Active Directory Functions - Example 1", "User '" & $aUser & "' does not exist")
ElseIf @error = 2 Then
 MsgBox(64, "Active Directory Functions - Example 1", "User '" & $aUser & "' already has a mailbox defined")
Else
 MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & $aUser &"' from Active Directory")
EndIf 

_AD_Close()
; Open Connection to the Active Directory

I'm testing as I go, so right now, the issue is, with just creating a new user. I get error -2147352567

AD UDF v 1.2.0

Scriptline 2182

Hex 80020009

WinDescription - An invalid dn syntax has been specified.

Windows 7 x64 (running script as x86)

Any help would be greatly appreciated.

FYI, I also get the error just running the _AD_CreateUser.au3

Thank you

edit:

Updated to latest code

Edited by bcdietz
Link to comment
Share on other sites

After calling _AD_Open could you please display the content of variable $sAD_DNSDomain?

The line in error takes this variable ("DC=microsoft,DC=com") and uses it to create the userPrincipalName.

If your domain isn't of format "DC=xxx,DC=yyy" this might cause the error.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Can you post the parameters you pass to function "_AD_CreateUser"? Replace confidential information with "xxxx". I just need the "structure".

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Ah, that's easy :)

As the cn (common name) you pass as third parameter ("tester, test d") contains a comma you have to escape the special characters in this string.

Pass the 3rd parameter as _AD_FixSpecialChars("tester, test d") and everything will be fine.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Thanks :)

I will check the function if the escape could be done automatically.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

water, sorry to bug you again. I'm having an issue with creating a maibox for the user now.

Code i'm sending: (snippit from code it has the _ad_open() etc)

Global $iValue = _AD_CreateUser($suOU, $slogon, _AD_FixSpecialChars($sname))
$aUser = _AD_SamAccountNameToFQDN($slogon)
_AD_SetPasswordExpire($aUser,0)
_AD_ModifyAttribute($aUser, "givenName", $sfname)
_AD_ModifyAttribute($aUser, "initials", $sminitial)
_AD_ModifyAttribute($aUser, "displayName", $sname)
_AD_ModifyAttribute($aUser, "sn", $slname)
_AD_ModifyAttribute($aUser, "description", $sDescription)
_AD_ModifyAttribute($aUser, "extensionAttribute1", $sEmpNum)
_AD_ModifyAttribute($aUser, "extensionAttribute9", $sEmployee)
_AD_ModifyAttribute($aUser, "physicalDeliveryOfficeName", $soffice)
_AD_ModifyAttribute($aUser, "telephoneNumber", $sphone)
_AD_ModifyAttribute($aUser, "wWWHomePage", $sweb)
_AD_ModifyAttribute($aUser, "postOfficeBox", $spo)
_AD_ModifyAttribute($aUser, "l", $scity)
_AD_ModifyAttribute($aUser, "st", $sstate)
_AD_ModifyAttribute($aUser, "postalCode", $szip)
_AD_ModifyAttribute($aUser, "co", "United States")
_AD_ModifyAttribute($aUser, "info", "Account created on " & @MON & "/" & @MDAY & "/" & @YEAR & " by " & @UserName )
sleep(500)

$eMBX = "FifthSG-DB"
$eis = "Fifth Storage Group"
$esv = "EXCH-MB1"
Global $iValue = _AD_CreateMailbox($aUser,$eMBX,$eis,$esv)

it creates the user and updates all the attibutes. But when I try to create a mailbox it errors.

Error:

Scriptline = 3775

Hex 80020006

Number = -2147352570

WinDesc = Unknown name

LastDLLerror = 14007

Any ideas?

Link to comment
Share on other sites

Please check the remarks for function _AD_CreateMailbox:

; Remarks .......: The mailbox is created using CDOEXM. For this function to work the Exchange administration tools have to be installed on the
;                 computer running the script.
;                 To set rights on the mailbox you have to run at least Exchange 2000 SP2.
;+
;                 If the Exchange administration tools are not installed on the PC running the script you could use an ADSI only solution.
;                 Set the mailNickname and displayName properties of the user and at least one of this: homeMTA, homeMDB or msExchHomeServerName and
;                 the RUS (Recipient Update Service) of Exchange 2000/2003 will create the mailbox for you.
;                 Be aware that this no longer works for Exchange 2007 and later.
If you use Exchange 2007 or later you have to use PowerShell to create a mailbox. If needed I can provide an example.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

This is the code snipped taken from our user creation script:

;------------------------------------------------------------------------------------------
; Create mailbox using powershell. Syntax: http://technet.microsoft.com/en-us/library/aa998251.aspx
; http://www.autoitscript.com/forum/topic/106163-active-directory-udf/page__view__findpost__p__912626
;------------------------------------------------------------------------------------------
$sCMD = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command . " & _
    "'D:\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Enable-Mailbox -Identity " & _
    $Kurzzeichen & " -Alias " & $Kurzzeichen & " -Database " & $sEXDatabase
$PID = Run($sCMD, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD)
StdinWrite($PID, @CRLF)
StdinWrite($PID)
; Records from STDOUT
$sSTDOUT = ""
While 1
    $sOutput = StdoutRead($pid)
    If @error Then ExitLoop
    If $sOutput <> "" Then $sSTDOUT = $sSTDOUT & @CRLF & $sOutput
WEnd
; Records from STDERR
$sSTDERR = ""
While 1
    $sOutput = StdErrRead($pid)
    If @error Then ExitLoop
    If $sOutput <> "" Then $sSTDERR = $sSTDERR & @CRLF & $sOutput
WEnd
If StringStripWS($sSTDERR, 3) = "" Then
    ; Everything OK
Else
    ; Error creating mailbox. Errortext is in $sSTDERR)
Endif

$Kurzzeichen is the userid e.g. @Username

$sEXDatabase is the name of the Exchange database

The script takes a lot of time to create the mailbox (about 1 minute here) because PS is so slooowww ...

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

#include <AD.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <Constants.au3>

#Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\Forms\NewUser.kxf
Global $Form1_1 = GUICreate("NewUser", 579, 665, 221, 127)
Global $fname = GUICtrlCreateInput("", 16, 40, 129, 21)
Global $help = GUICtrlCreateButton("?", 544, 8, 25, 25)
_No_TABSTOP($help)
GUICtrlSetFont($help, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor($help, 0x0000FF)
GUICtrlSetTip($help, "About")
Global $minitial = GUICtrlCreateInput("", 168, 40, 57, 21)
GUICtrlSetLimit($minitial, 1)
Global $lname = GUICtrlCreateInput("", 248, 40, 145, 21)
Global $Label1 = GUICtrlCreateLabel("First Name", 16, 16, 54, 17)
Global $Label2 = GUICtrlCreateLabel("Initials", 168, 16, 33, 17)
Global $Label3 = GUICtrlCreateLabel("Last Name", 248, 16, 55, 17)
Global $name = GUICtrlCreateInput("", 16, 96, 377, 21)
Global $logon = GUICtrlCreateInput("", 16, 152, 129, 21)
Global $Label4 = GUICtrlCreateLabel("Name", 16, 72, 32, 17)
Global $Label5 = GUICtrlCreateLabel("User Logon Name", 16, 128, 90, 17)
Global $Label6 = GUICtrlCreateLabel("Password", 208, 128, 50, 17)
Local $varpassword = IniRead("NewUser.ini", "NewUser", "password", "")
Global $password = GUICtrlCreateInput($varpassword, 208, 152, 185, 21)
Global $Label10 = GUICtrlCreateLabel("User OU", 16, 184, 45, 17)
Global $ListOU = GUICtrlCreateCombo("", 16, 208, 377, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE))
GUICtrlSetTip($ListOU, "Location where User will work.")
Global $valid = GUICtrlCreateLabel("Valid", 120, 128, 27, 17)
GUICtrlSetColor($valid, 0x00FF00)
GUICtrlSetState($valid, $GUI_HIDE)
Global $invalid = GUICtrlCreateLabel("Invalid", 120, 128, 35, 17)
GUICtrlSetColor($invalid, 0xFF0000)
GUICtrlSetState($invalid, $GUI_HIDE)
Global $Label8 = GUICtrlCreateLabel("Employee Number", 16, 247, 90, 17)
Global $c_attribute1 = GUICtrlCreateInput("", 16, 271, 113, 21)
Global $c_attribute9 = GUICtrlCreateCheckbox("CPS Employee", 188, 263, 113, 33)
GUICtrlSetState($c_attribute9, $GUI_CHECKED)
Local $vardate = IniRead("NewUser.ini", "NewUser", "dateforward", "")
Global $date = GUICtrlCreateDate(_DateAdd('d', $vardate, _NowCalcDate()), 320, 272, 209, 25)
GUICtrlSetState($date, $GUI_HIDE)
Global $Label7 = GUICtrlCreateLabel("Description", 16, 304, 57, 17)
Global $Description = GUICtrlCreateInput("", 16, 336, 385, 21)
Global $Label9 = GUICtrlCreateLabel("Office", 16, 376, 32, 17)
Global $office = GUICtrlCreateInput("", 16, 400, 129, 21)
Global $Label11 = GUICtrlCreateLabel("Telephone", 160, 376, 55, 17)
Global $phone = GUICtrlCreateInput("", 160, 400, 129, 21)
Global $Label12 = GUICtrlCreateLabel("Web page", 304, 376, 54, 17)
Local $varweb = IniRead("NewUser.ini", "NewUser", "web", "")
Global $web = GUICtrlCreateInput($varweb, 304, 400, 153, 21)
Local $varpo = IniRead("NewUser.ini", "NewUser", "po", "1771")
Global $po = GUICtrlCreateInput($varpo, 16, 456, 57, 21)
Local $varcity = IniRead("NewUser.ini", "NewUser", "city", "San Antonio")
Global $city = GUICtrlCreateInput($varcity, 80, 456, 81, 21)
Local $varstate = IniRead("NewUser.ini", "NewUser", "state", "Texas")
Global $state = GUICtrlCreateInput($varstate, 168, 456, 57, 21)
Local $varzip = IniRead("NewUser.ini", "NewUser", "zip", "78296")
Global $zip = GUICtrlCreateInput($varzip, 232, 456, 49, 21)
Global $Label13 = GUICtrlCreateLabel("P.O. Box, City, State, Zip", 16, 432, 121, 17)
Global $btn_create = GUICtrlCreateButton("Create", 440, 608, 97, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$iAD_Debug = 2
Local $mydc = IniRead("NewUser.ini", "NewUser", "dc", "")
if _AD_Open("","","",$mydc) Then
   ;MsgBox(64, "Active Directory Functions", "Logon was succcessful!")
    ElseIf @error <= 8 Then
            MsgBox(16, "Active Directory Functions", "The logon was not succcessful!" & @CRLF & @CRLF & "@error: " & @error & ", @extended: " & @extended)
    Else
            MsgBox(16, "Active Directory Functions", "The logon was not succcessful!" & @CRLF & @CRLF & "@error: " & @error & ", @extended: " & @extended & _
                   @CRLF & @CRLF & "Extended error information will be displayed")
   Global $aError = _AD_GetLastADSIError()
                _ArrayDisplay($aError)
     EndIf
Global $sdate = ""
Global $sOU
Local $varadou = IniRead("NewUser.ini", "NewUser", "adou", "")
Global $adOU = _AD_GetObjectsInOU($varadou,"(objectCategory=organizationalUnit)",1,"name,distinguishedName","name")
;_ArrayDisplay($adOU, "Active Directory Functions - Example 1 - Objects in OU '" & $adOU & "'")
For $iCount = 1 To $adOU[0][0]
     If $iCount = 1 Then
       $sOU = $adOU[$iCount][0]
     Else
       $sOU = $sOU & "|" & $adOU[$iCount][0]
    EndIf
Next
GUICtrlSetData($ListOU,$sOU)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  
  Case $c_attribute1
  Case $c_attribute9
   Global $sc_attribute9 = GUICtrlRead($c_attribute9)
   if $sc_attribute9 = $GUI_UNCHECKED Then
   GUICtrlSetState($date, $GUI_SHOW)
   else
   GUICtrlSetState($date, $GUI_HIDE)
   endif
  Case $fname
  Case $minitial
  Case $lname
   Global $sfname = GUICtrlRead($fname)
   Global $slname = GUICtrlRead($lname)
   Global $sminitial = GUICtrlRead($minitial)
   GuiCtrlSetData($name,$slname & ", " & $sfname & " " & $sminitial)
   Global $sfl = StringRegExp($sfname,'\A\D',1)
   GuiCtrlSetData($logon, $sfl[0] & $sminitial & $slname)
   Global $slogon = GUICtrlRead($logon)
   $aUser = _AD_SamAccountNameToFQDN($slogon)
   if $aUser = "" Then
   GUICtrlSetState($valid, $GUI_SHOW)
   GUICtrlSetState($invalid, $GUI_HIDE)
   else
   GUICtrlSetState($invalid, $GUI_SHOW)
   GUICtrlSetState($valid, $GUI_HIDE)
   endif
  Case $name
  
  Case $logon
   Global $slogon = GUICtrlRead($logon)
   $aUser = _AD_SamAccountNameToFQDN($slogon)
   if $aUser = "" Then
   GUICtrlSetState($valid, $GUI_SHOW)
   GUICtrlSetState($invalid, $GUI_HIDE)
   else
   GUICtrlSetState($invalid, $GUI_SHOW)
   GUICtrlSetState($valid, $GUI_HIDE)
   endif
  
  Case $password
  Case $btn_create
   $sfname = GUICtrlRead($fname)
   $sminitial = GUICtrlRead($minitial)
   $slname = GUICtrlRead($lname)
  
   $slogon = GUICtrlRead($logon)
   $sname = GUICtrlRead($name)  
   $sListOU = GUICtrlRead($ListOU)
   $suOUnum = _ArraySearch($adOU,$sListOU,0,0,0,0,1,0)
   $suOU = $adOU[$suOUnum][1]
   $sEmpNum = GUICtrlRead($c_attribute1)
   $sEmployee = GUICtrlRead($c_attribute9)
   if $sEmployee = $GUI_UNCHECKED Then
   $sEmployee = "No"
   $sdate = GUICtrlRead($date)
   else
   $sEmployee = "Yes"
   endif
   $sdescription = GUICtrlRead($description)
   $soffice = GUICtrlRead($office)
   $sphone = GUICtrlRead($phone)
   $sweb = GUICtrlRead($web)
   $spo = GUICtrlRead($po)
   $scity = GUICtrlRead($city)
   $sstate = GUICtrlRead($state)
   $szip = GUICtrlRead($zip)

   ExitLoop
  Case $ListOU
EndSwitch
WEnd
Global $iValue = _AD_CreateUser($suOU, $slogon, _AD_FixSpecialChars($sname))
$aUser = _AD_SamAccountNameToFQDN($slogon)
_AD_SetPasswordExpire($aUser,0)
_AD_ModifyAttribute($aUser, "givenName", $sfname)
_AD_ModifyAttribute($aUser, "initials", $sminitial)
_AD_ModifyAttribute($aUser, "displayName", $sname)
_AD_ModifyAttribute($aUser, "sn", $slname)
_AD_ModifyAttribute($aUser, "description", $sDescription)
_AD_ModifyAttribute($aUser, "extensionAttribute1", $sEmpNum)
_AD_ModifyAttribute($aUser, "extensionAttribute9", $sEmployee)
_AD_ModifyAttribute($aUser, "physicalDeliveryOfficeName", $soffice)
_AD_ModifyAttribute($aUser, "telephoneNumber", $sphone)
_AD_ModifyAttribute($aUser, "wWWHomePage", $sweb)
_AD_ModifyAttribute($aUser, "postOfficeBox", $spo)
_AD_ModifyAttribute($aUser, "l", $scity)
_AD_ModifyAttribute($aUser, "st", $sstate)
_AD_ModifyAttribute($aUser, "postalCode", $szip)
_AD_ModifyAttribute($aUser, "countryCode", "0")
_AD_ModifyAttribute($aUser, "info", "Account created on " & _NowCalcDate() & " by " & @UserName)
if $sdate = "" then
;Nothing
else
Local $sFormatIn = "dddd, MMMM d, yyyy"
$sdate = _Date_Time_Convert($sdate, $sFormatIn)
_AD_SetAccountExpire($aUser, $sdate)
endif

Local $eMBX = IniRead("NewUser.ini", "NewUser", "embx", "")
$cmd = "{Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin};Enable-Mailbox -Identity:'"& $aUser & "' -Alias:'" & $slogon & "' -Database:'" & $eMBX & "' -DomainController " & $mydc & ""
$sCMD = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command . " & $cmd
$PID = Run($sCMD, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD)
StdinWrite($PID, @CRLF)
StdinWrite($PID)
; Records from STDOUT
$sSTDOUT = ""
While 1
    $sOutput = StdoutRead($pid)
    If @error Then ExitLoop
    If $sOutput <> "" Then $sSTDOUT = $sSTDOUT & @CRLF & $sOutput
WEnd
; Records from STDERR
$sSTDERR = ""
While 1
    $sOutput = StdErrRead($pid)
    If @error Then ExitLoop
    If $sOutput <> "" Then $sSTDERR = $sSTDERR & @CRLF & $sOutput
WEnd
If StringStripWS($sSTDERR, 3) = "" Then
    ; Everything OK
;msgbox (64, "Output", $sSTDERR & "Good")
Else
    ; Error creating mailbox. Errortext is in $sSTDERR)
;msgbox (64, "Output", $sSTDERR & "Bad")
Endif


_AD_Close()
Func _No_TABSTOP($iCID)

    _WinAPI_SetWindowLong(GUICtrlGetHandle($iCID), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle($iCID), $GWL_STYLE), BitNOT($WS_TABSTOP)))

EndFunc
; #FUNCTION# ==================================================================================
; Name...........: _Date_Time_Convert
; Description ...: Converts a date and/or time from its existing format to any other custom format.
; Example Date time "Thursday, 1 April, 2010 @ 08:05:08 PM"
; Example's Format Eg : "dddd, d MMMM, yyyy @ hh:mm:ss tt"
; Year. : yyyy = 2010 ; yy = 10
; Month : MMMM = April; MMM = Apr; MM = 04; M = 4
; Day.. : dddd = Thursday; ddd = Thu; dd = 01; d = 1
; Hour. : HH = 20; H = 20 (1 digit minimum); hh = 08; h = 8 (Lowercase h's used with AM/PM time)
; Minute: mm = 05 (2 digit minimum); m = 5 (1 digit minimum)
; Second: ss = 08 (2 digit minimum); s = 8 (1 digit minimum)
; AM/PM : tt = AM or PM; t = A or P
; Ref: Format Strings @ [url="http://msdn.microsoft.com/en-us/library/bb761726%28v=VS.85%29.aspx#dtp_format_chars"]http://msdn.microsoft.com/en-us/library/bb761726%28v=VS.85%29.aspx#dtp_format_chars[/url]
; =============================================================================================
Func _Date_Time_Convert($sDateTime, $sDateTimeFormat, $sRetFormat = "yyyy/MM/dd HH:mm:ss")
    Local $Time, $iYear, $iMnth, $iDay, $iHour, $iMinute, $iSec, $aFormatIn, $msg
    Local $aMMM[12] = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
    $aFormatIn = StringRegExp($sDateTimeFormat, "(y+|M+|d+|H+|h+|m+|s+|t+)", 3) ;Array of format characters.
    For $i = 0 To UBound($aFormatIn) - 1
        $msg = StringLeft($aFormatIn[$i], 1)
        Select
            Case $msg = "y" ; y - Year
                If StringLen($aFormatIn[$i]) = 4 Then _
                        $iYear = StringMid($sDateTime, StringInStr($sDateTimeFormat, "yyyy"), _
                                StringLen($aFormatIn[$i])) & "/"
                If StringLen($aFormatIn[$i]) = 2 Then
                    $iYear = StringMid($sDateTime, StringInStr($sDateTimeFormat, "yy"), 2)
                    If Number($iYear) < Number(StringRight(@YEAR, 2) + 20) Then
                        $iYear = "20" & $iYear & "/"
                    Else
                        $iYear = "19" & $iYear & "/"
                    EndIf
                EndIf
            Case StringRegExp($msg, "M") ; M - Month
                If StringLen($aFormatIn[$i]) > 2 Then
                    $iMnth = StringMid($sDateTime, StringInStr($sDateTimeFormat, "MMM", 1), 3)
                    If StringLen($aFormatIn[$i]) < 3 Then _
                            $iMnth = StringMid($sDateTime, StringInStr($sDateTimeFormat, "MMM", 1) + 1, 2)
                    $sDateTime = StringRegExpReplace($sDateTime, "\b(" & $iMnth & ".*?)\b", $iMnth)
                    $sDateTimeFormat = StringRegExpReplace($sDateTimeFormat, "\b(M{3})(M*)\b", "\1")
                EndIf
                If StringLen($aFormatIn[$i]) > 2 Then
                    For $j = 0 To UBound($aMMM) - 1
                        If StringLeft($iMnth, 3) = $aMMM[$j] Then $iMnth = StringRight("0" & $j + 1, 2) & "/"
                    Next
                ElseIf StringLen($aFormatIn[$i]) < 3 Then
                    $iMnth = Number(StringMid($sDateTime, StringInStr($sDateTimeFormat, "M", 1), 2))
                    If $iMnth > 9 And StringLen($aFormatIn[$i]) = 1 Then $sDateTimeFormat = _
                            StringRegExpReplace($sDateTimeFormat, "(?:\b|[^M])(M)(?:\b|[^M])", " MM")
                    $iMnth = StringRight("0" & $iMnth, 2) & "/"
                EndIf
            Case $msg = "d" ; d - Day
                If StringLen($aFormatIn[$i]) > 2 Then
                    $iDay = StringMid($sDateTime, StringInStr($sDateTimeFormat, "ddd", 1), 3)
                    $sDateTime = StringRegExpReplace($sDateTime, "\b(" & $iDay & ".*?)\b", "")
                    $sDateTimeFormat = StringRegExpReplace($sDateTimeFormat, "\b(d{3})(d*)\b", "")
                EndIf
                If StringLen($aFormatIn[$i]) <= 2 Then
                    $iDay = Number(StringMid($sDateTime, StringInStr($sDateTimeFormat, "d", 1), 2))
                    If $iDay > 9 And StringLen($aFormatIn[$i]) = 1 Then $sDateTimeFormat = _
                            StringRegExpReplace($sDateTimeFormat, "(?:\b|[^d])(d)(?:\b|[^d])", " dd")
                EndIf
                $iDay = StringRight("0" & $iDay, 2) & " "
            Case StringRegExp($msg, "(?i)h") ; H or h - Hour
                If StringInStr($sDateTimeFormat, "H", 1) Then
                    $iHour = StringRight("0" & Number(StringMid($sDateTime, _
                            StringInStr($sDateTimeFormat, "H", 1), 2)), 2)
                ElseIf StringInStr($sDateTimeFormat, "h", 1) Then
                    $iHour = Number(StringMid($sDateTime, StringInStr($sDateTimeFormat, "h", 1), 2))
                EndIf
                If StringInStr($sDateTime, "AM") And $iHour = 12 Then $iHour = 0
                If StringInStr($sDateTime, "PM") And $iHour < 12 Then $iHour += 12
                If $iHour > 9 And StringLen($aFormatIn[$i]) = 1 Then $sDateTimeFormat = _
                        StringRegExpReplace($sDateTimeFormat, "(?i)(?:\b|[^h])(h)(?:\b|[^h])", " hh")
                $iHour = StringRight("0" & $iHour, 2) & ":"
            Case StringRegExp($msg, "m") ; m - Minute
                If StringInStr($sDateTimeFormat, "m", 1) Then
                    $iMinute = Number(StringMid($sDateTime, StringInStr($sDateTimeFormat, "m", 1), 2))
                EndIf
                If $iMinute > 9 And StringLen($aFormatIn[$i]) = 1 Then $sDateTimeFormat = _
                        StringRegExpReplace($sDateTimeFormat, "(?:\b|[^m])(m)(?:\b|[^m])", " mm")
                $iMinute = StringRight("0" & $iMinute, 2) & ":"
            Case $msg = "s" ; s - Second
                If StringInStr($sDateTimeFormat, "ss") Then
                    $iSec = StringMid($sDateTime, StringInStr($sDateTimeFormat, "ss"), 2)
                EndIf
                If $iSec > 9 And StringLen($aFormatIn[$i]) = 1 Then $sDateTimeFormat = _
                        StringRegExpReplace($sDateTimeFormat, "(?:\b|[^s])(s)(?:\b|[^s])", " ss")
                $iSec = StringRight("0" & $iSec, 2) & ":"
        EndSelect
    Next
    ; Default values added to empty, unused variables for entry into the Date Control.
    If $iYear = "" Then $iYear = "1900/"
    If $iMnth = "" Then $iMnth = "01/"
    If $iDay = "" Then $iDay = "01 "
    If $iHour = "" Then $iHour = "00:"
    If $iMinute = "" Then $iMinute = "00:"
    If $iSec = "" Then $iSec = "00"
    $Time = $iYear & $iMnth & $iDay & $iHour & $iMinute & $iSec
    ;===== The following converts $Time to $sRetFormat format usind Date Control ======
    ; $Time is now in this format "yyyy/MM/dd HH:mm:ss"
    Local $hGui = GUICreate("My GUI get date", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate($Time, 10, 10, 185, 20)
    GUICtrlSendMsg($idDate, 0x1032, 0, $sRetFormat)
    Local $sReturn = GUICtrlRead($idDate)
    GUIDelete($hGui)
    Return $sReturn
EndFunc ;==>_Date_Time_Convert
; Open Connection to the Active Directory

That did it. Thanks for your help. Here is the almost completed script.

I added a NewUser.ini file for the configuration, incase some things change. Also, I change your powershell command to include the -domaincontroler option, that way both commands run against the same DC. else replication would have to happen REAL quick. :)

NewUser.ini

[NewUser]
password=Password01
dateforward=60
web=http://www.xxxxxxx.com
po=xxxx
city=xxxx
state=xxxxx
zip=xxxx
dc=xxxx.xxxx.com
adou=OU=USERS,OU=xxxx,DC=xxxx,DC=com
embx=EXCH-MB1\Storage Group\SG-DB1
Link to comment
Share on other sites

Thanks for posting your script. This might be useful for other users having the same "problem" in the future.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Ok, riddle me this.. The 'script' works just fine on my machine. But when I compile it, the Powershell doesn't run. So no exchange mailbox. The user is created flawlessly. I've tried running as administrator but no go.

Also, Water at line:

$start_ie = _IECreate($startURL,0,0)

I get an error Number -2147352567 Unspecified error at line 3677 whenever I run an _IECreate(). I know you didn't create IE.AU3 but it's AD.AU3 that errors.

3677 - EndFunc ;==>_AD_UnJoinDomain

#include <AD.au3>
#include <IE.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <Constants.au3>

#Region ### START Koda GUI section ### Form=C:Program Files (x86)AutoIt3FormsNewUser.kxf
Global $Form1_1 = GUICreate("NewUser", 579, 665, 221, 127)
Global $help = GUICtrlCreateButton("?", 544, 8, 25, 25)
GUICtrlSetFont($help, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor($help, 0x0000FF)
GUICtrlSetTip($help, "About")
Global $fname = GUICtrlCreateInput("", 16, 40, 129, 21)
Global $minitial = GUICtrlCreateInput("", 168, 40, 57, 21)
GUICtrlSetLimit($minitial, 1)
Global $lname = GUICtrlCreateInput("", 248, 40, 145, 21)
GUICtrlSetLimit($lname, 12)
Global $Label1 = GUICtrlCreateLabel("First Name", 16, 16, 54, 17)
Global $Label2 = GUICtrlCreateLabel("Initials", 168, 16, 33, 17)
Global $Label3 = GUICtrlCreateLabel("Last Name", 248, 16, 55, 17)
Global $name = GUICtrlCreateInput("", 16, 96, 377, 21)
Global $logon = GUICtrlCreateInput("", 16, 152, 129, 21)
Global $Label4 = GUICtrlCreateLabel("Name", 16, 72, 32, 17)
Global $Label5 = GUICtrlCreateLabel("User Logon Name", 16, 128, 90, 17)
Global $Label6 = GUICtrlCreateLabel("Password", 208, 128, 50, 17)
Local $varpassword = IniRead("NewUser.ini", "NewUser", "password", "")
Global $password = GUICtrlCreateInput($varpassword, 208, 152, 185, 21)
Global $Label10 = GUICtrlCreateLabel("User OU", 16, 184, 45, 17)
Global $ListOU = GUICtrlCreateCombo("", 16, 208, 377, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE))
GUICtrlSetTip($ListOU, "Location where User will work.")
Global $valid = GUICtrlCreateLabel("Valid", 120, 128, 27, 17)
GUICtrlSetColor($valid, 0x00FF00)
GUICtrlSetState($valid, $GUI_HIDE)
Global $invalid = GUICtrlCreateLabel("Invalid", 120, 128, 35, 17)
GUICtrlSetColor($invalid, 0xFF0000)
GUICtrlSetState($invalid, $GUI_HIDE)
Global $Label8 = GUICtrlCreateLabel("Employee Number", 16, 247, 90, 17)
Global $c_attribute1 = GUICtrlCreateInput("", 16, 271, 113, 21)
Global $c_attribute9 = GUICtrlCreateCheckbox("Employee", 140, 263, 97, 33)
GUICtrlSetState($c_attribute9, $GUI_CHECKED)
Global $fulltime = GUICtrlCreateCheckbox("Full Time", 256, 263, 65, 33)
GUICtrlSetState($fulltime, $GUI_CHECKED)
Local $vardate = IniRead("NewUser.ini", "NewUser", "dateforward", "")
Global $date = GUICtrlCreateDate(_DateAdd('d', $vardate, _NowCalcDate()), 360, 267, 97, 25, 0)
GUICtrlSetState($date, $GUI_HIDE)
Global $Label7 = GUICtrlCreateLabel("Description", 16, 304, 57, 17)
Global $Description = GUICtrlCreateInput("", 16, 336, 377, 21)
Global $Label9 = GUICtrlCreateLabel("Office", 16, 376, 32, 17)
Global $office = GUICtrlCreateInput("", 16, 400, 129, 21)
Global $Label11 = GUICtrlCreateLabel("Telephone", 160, 376, 55, 17)
Global $phone = GUICtrlCreateInput("", 160, 400, 129, 21)
Global $Label12 = GUICtrlCreateLabel("Web page", 304, 376, 54, 17)
Local $varweb = IniRead("NewUser.ini", "NewUser", "web", "")
Global $web = GUICtrlCreateInput($varweb, 304, 400, 153, 21)
Local $varpo = IniRead("NewUser.ini", "NewUser", "po", "")
Global $po = GUICtrlCreateInput($varpo, 16, 456, 57, 21)
Local $varcity = IniRead("NewUser.ini", "NewUser", "city", "")
Global $city = GUICtrlCreateInput($varcity, 80, 456, 81, 21)
Local $varstate = IniRead("NewUser.ini", "NewUser", "state", "")
Global $state = GUICtrlCreateInput($varstate, 168, 456, 57, 21)
Local $varzip = IniRead("NewUser.ini", "NewUser", "zip", "")
Global $zip = GUICtrlCreateInput($varzip, 232, 456, 49, 21)
Global $Label13 = GUICtrlCreateLabel("P.O. Box, City, State, Zip", 16, 432, 121, 17)
Global $btn_create = GUICtrlCreateButton("Create", 440, 608, 97, 33)
Global $mailbox = GUICtrlCreateCheckbox("Create Mailbox", 440, 80, 105, 25)
GUICtrlSetState($mailbox, $GUI_CHECKED)
Global $homedrive = GUICtrlCreateCheckbox("Create Homedrive", 440, 111, 105, 25)
GUICtrlSetState($homedrive, $GUI_CHECKED)
Global $Label14 = GUICtrlCreateLabel("Additional Groups", 24, 488, 111, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $mydebug = IniRead("NewUser.ini", "NewUser", "debug", "")
$iAD_Debug = $mydebug
Global $mydc = IniRead("NewUser.ini", "NewUser", "dc", "")
if _AD_Open("","","",$mydc) Then
   ;MsgBox(64, "Active Directory Functions", "Logon was succcessful!")
    ElseIf @error <= 8 Then
            MsgBox(16, "Active Directory Functions", "The logon was not succcessful!" & @CRLF & @CRLF & "@error: " & @error & ", @extended: " & @extended)
    Else
            MsgBox(16, "Active Directory Functions", "The logon was not succcessful!" & @CRLF & @CRLF & "@error: " & @error & ", @extended: " & @extended & _
                   @CRLF & @CRLF & "Extended error information will be displayed")
   Global $aError = _AD_GetLastADSIError()
                _ArrayDisplay($aError)
     EndIf
Global $sdate = ""
Global $sOU
Local $varadou = IniRead("NewUser.ini", "NewUser", "adou", "")
Global $adOU = _AD_GetObjectsInOU($varadou,"(objectCategory=organizationalUnit)",1,"name,distinguishedName","name")
;_ArrayDisplay($adOU, "Active Directory Functions - Example 1 - Objects in OU '" & $adOU & "'")
For $iCount = 1 To $adOU[0][0]
     If $iCount = 1 Then
       $sOU = $adOU[$iCount][0]
     Else
       $sOU = $sOU & "|" & $adOU[$iCount][0]
    EndIf
Next
GUICtrlSetData($ListOU,$sOU)

  $lmangroups = IniRead("NewUser.ini", "NewUser", "mangroups", "")
global $mangroups = stringsplit($lmangroups,'|')
global $addgroupchkbox[($mangroups[0] +1)]
$start = 500
$col = 24
$row = 0
;msgbox(0,"Mangroup",$mangroups[0])
for $i = 1 to ($mangroups[0])
  ;msgbox(0,"Mangroup",$mangroups[0] & " - " & $i & " - " & $start & " - " & $addgroup[0] )
  $addgroupchkbox[$i] = GUICtrlCreateCheckbox($mangroups[$i], $col, $start, 130, 25)
  $row = $row +1
  $start += 20
  if $row = 5 then
   $col = $col + 150
   $start = 500
   $row = 0
  endif
  ;_AD_AddUserToGroup($autogroups[$i], $aUser)
  
next
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  
  Case $c_attribute1
  Case $c_attribute9
  Case $fname
  Case $minitial
  Case $help
   msgbox(0,"About", "NewUser.exe" & @crlf & @crlf & "Created by Brian Dietz for my company" & @CRLF & @CRLF & "Version 1.0" & @CRLF & "For help, please open a HPSM Ticket for Network Admin - Windows, with a description of the problem, and a screenshot of the error" & @CRLF & @CRLF & "Thank you")
  Case $lname
   Global $sfname = GUICtrlRead($fname)
   Global $slname = GUICtrlRead($lname)
   Global $sminitial = GUICtrlRead($minitial)
   GuiCtrlSetData($name,$slname & ", " & $sfname & " " & $sminitial)
   Global $sfl = StringRegExp($sfname,'AD',1)
   GuiCtrlSetData($logon, $sfl[0] & $sminitial & $slname)
   Global $slogon = GUICtrlRead($logon)
   $aUser = _AD_SamAccountNameToFQDN($slogon)
   if $aUser = "" Then
    GUICtrlSetState($valid, $GUI_SHOW)
    GUICtrlSetState($invalid, $GUI_HIDE)
   else
    GUICtrlSetState($invalid, $GUI_SHOW)
    GUICtrlSetState($valid, $GUI_HIDE)
   endif
   $startURL = "http://mywebpage.htm?lastname=" & $slname & "&firstname=" & $sfname & "&submit=Search"
   $start_ie = _IECreate($startURL,0,0)
   $open_Table = _IETableGetCollection ($start_ie,5)
   $aTableData = _IETableWriteToArray ($open_Table, True)
   GUICtrlSetData($description,$aTableData[1][4])
   GUICtrlSetData($office,$aTableData[1][2])
   GUICtrlSetData($phone,"210-353-" & $aTableData[1][1])
  Case $name
  Case $mailbox
  Case $fulltime
   Global $sfulltime = GUICtrlRead($fulltime)
   if $sfulltime = $GUI_UNCHECKED Then
    GUICtrlSetState($date, $GUI_SHOW)
   else
    GUICtrlSetState($date, $GUI_HIDE)
   endif  
  Case $logon
   Global $slogon = GUICtrlRead($logon)
   $aUser = _AD_SamAccountNameToFQDN($slogon)
   if $aUser = "" Then
   GUICtrlSetState($valid, $GUI_SHOW)
   GUICtrlSetState($invalid, $GUI_HIDE)
   else
   GUICtrlSetState($invalid, $GUI_SHOW)
   GUICtrlSetState($valid, $GUI_HIDE)
   endif
  
  Case $password
  Case $btn_create
   $cuser = _Create_User()
   if $cuser = 0 then
    $createdUser = _AD_GetObjectProperties($aUser)
    _ArrayDisplay($createdUser, "User Created Successfully")
    ;msgbox(4096,"Create User", $cuser)
    ;ExitLoop
   else
    msgbox(4096,"Create User", "Whoops " & $cuser )
   endif
  Case $ListOU
EndSwitch
WEnd

_AD_Close()
Func _Create_User()
$sfname = GUICtrlRead($fname)
$sminitial = GUICtrlRead($minitial)
$slname = GUICtrlRead($lname)

Global $slogon = GUICtrlRead($logon)
$sname = GUICtrlRead($name)  
$spassword = GUICtrlRead($password)
$sListOU = GUICtrlRead($ListOU)
$suOUnum = _ArraySearch($adOU,$sListOU,0,0,0,0,1,0)
$suOU = $adOU[$suOUnum][1]
$sEmpNum = GUICtrlRead($c_attribute1)
$sEmployee = GUICtrlRead($c_attribute9)
if $sEmployee = $GUI_UNCHECKED Then
  $sEmployee = "No"
else
  $sEmployee = "Yes"
endif
$sfulltime = GUICtrlRead($fulltime)
if $sfulltime = $GUI_UNCHECKED Then
  $sdate = GUICtrlRead($date)
else
  $sdate = ""
endif
$sdescription = GUICtrlRead($description)
$soffice = GUICtrlRead($office)
$sphone = GUICtrlRead($phone)
$sweb = GUICtrlRead($web)
$spo = GUICtrlRead($po)
$scity = GUICtrlRead($city)
$sstate = GUICtrlRead($state)
$szip = GUICtrlRead($zip)
$smailbox = GUICtrlRead($mailbox)
$shomedrive = GUICtrlRead($homedrive)
Global $iValue = _AD_CreateUser($suOU, $slogon, _AD_FixSpecialChars($sname))
Global $aUser = _AD_SamAccountNameToFQDN($slogon)
_AD_SetPasswordExpire($aUser,0)
_AD_ModifyAttribute($aUser, "givenName", $sfname)
_AD_ModifyAttribute($aUser, "initials", $sminitial)
_AD_ModifyAttribute($aUser, "displayName", $sname)
_AD_ModifyAttribute($aUser, "sn", $slname)
_AD_ModifyAttribute($aUser, "description", $sDescription)
_AD_ModifyAttribute($aUser, "extensionAttribute1", $sEmpNum)
_AD_ModifyAttribute($aUser, "extensionAttribute9", $sEmployee)
_AD_ModifyAttribute($aUser, "physicalDeliveryOfficeName", $soffice)
_AD_ModifyAttribute($aUser, "telephoneNumber", $sphone)
_AD_ModifyAttribute($aUser, "wWWHomePage", $sweb)
_AD_ModifyAttribute($aUser, "postOfficeBox", $spo)
_AD_ModifyAttribute($aUser, "l", $scity)
_AD_ModifyAttribute($aUser, "st", $sstate)
_AD_ModifyAttribute($aUser, "postalCode", $szip)
_AD_ModifyAttribute($aUser, "c", "US")
_AD_ModifyAttribute($aUser, "co", "United States")
_AD_ModifyAttribute($aUser, "countryCode", "840")
_AD_SetPassword($aUser, $spassword,1)
_AD_ModifyAttribute($aUser, "info", "Account created on " & @MON & "/" & @MDAY & "/" & @YEAR & " by " & @UserName)

  $lautogroups = IniRead("NewUser.ini", "NewUser", "autogroups", "")
$autogroups = stringsplit($lautogroups,'|')
for $i = 1 to $autogroups[0]
  _AD_AddUserToGroup($autogroups[$i], $aUser)
next


for $i = 1 to (Ubound($addgroupchkbox) -1)
  $laddgroup = GUICtrlRead($addgroupchkbox[$i])
  if $laddgroup = $GUI_CHECKED Then
  _AD_AddUserToGroup($mangroups[$i], $aUser)
  endif
next

if StringRegExp( $slname,'A[a-dA-D]',0) then
_AD_AddUserToGroup("ssh-ad", $aUser)
elseif StringRegExp( $slname,'A[e-hE-H]',0) then
_AD_AddUserToGroup("ssh-eh", $aUser)
elseif StringRegExp( $slname,'A[i-lI-L]',0) then
_AD_AddUserToGroup("ssh-il", $aUser)
elseif StringRegExp( $slname,'A[m-pM-P]',0) then
_AD_AddUserToGroup("ssh-mp", $aUser)
elseif StringRegExp( $slname,'A[q-tQ-T]',0) then
_AD_AddUserToGroup("ssh-qt", $aUser)
elseif StringRegExp( $slname,'A[u-zU-Z]',0) then
_AD_AddUserToGroup("ssh-uz", $aUser)
endif
;msgbox(0,"Date",$sdate)
if $sdate = "" then
;Nothing
else
Local $sFormatIn = "MM/dd/yyyy"
$sdate = _Date_Time_Convert($sdate, $sFormatIn)
_AD_SetAccountExpire($aUser, $sdate)
endif
if $shomedrive = $GUI_CHECKED then
Local $lhomedrive = IniRead("NewUser.ini", "NewUser", "homedrive", "")
Local $lhomedir = IniRead("NewUser.ini", "NewUser", "homedir", "")
Local $lhomegroup = IniRead("NewUser.ini", "NewUser", "homegroup", "")
_AD_ModifyAttribute($aUser, "homeDrive", $lhomedrive)
_AD_ModifyAttribute($aUser, "homeDirectory", $lhomedir & $slogon)
_AD_AddUserToGroup($lhomegroup, $aUser)
else
endif
if $smailbox = $GUI_CHECKED then
Local $eMBX = IniRead("NewUser.ini", "NewUser", "embx", "")
$cmd = "{Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin};Enable-Mailbox -Identity:'"& $aUser & "' -Alias:'" & $slogon & "' -Database:'" & $eMBX & "' -DomainController " & $mydc & ""
$sCMD = "C:\Windows\System32\WindowsPowerShellv1.0powershell.exe -command . " & $cmd
$PID = Run($sCMD, @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD)
StdinWrite($PID, @CRLF)
StdinWrite($PID)
; Records from STDOUT
$sSTDOUT = ""
While 1
  $sOutput = StdoutRead($pid)
  If @error Then ExitLoop
  If $sOutput <> "" Then $sSTDOUT = $sSTDOUT & @CRLF & $sOutput
WEnd
; Records from STDERR
$sSTDERR = ""
While 1
  $sOutput = StdErrRead($pid)
  If @error Then ExitLoop
  If $sOutput <> "" Then $sSTDERR = $sSTDERR & @CRLF & $sOutput
WEnd
   If StringStripWS($sSTDERR, 3) = "" Then
    ; Everything OK
    ;msgbox (64, "Output", $sSTDERR & "Good")
   Else
    ; Error creating mailbox. Errortext is in $sSTDERR)
    ;msgbox (64, "Output", $sSTDERR & "Bad")
   Endif
else
endif
EndFunc

Func _No_TABSTOP($iCID)

    _WinAPI_SetWindowLong(GUICtrlGetHandle($iCID), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle($iCID), $GWL_STYLE), BitNOT($WS_TABSTOP)))

EndFunc
; #FUNCTION# ==================================================================================
; Name...........: _Date_Time_Convert
; Description ...: Converts a date and/or time from its existing format to any other custom format.
; Example Date time "Thursday, 1 April, 2010 @ 08:05:08 PM"
; Example's Format Eg : "dddd, d MMMM, yyyy @ hh:mm:ss tt"
; Year. : yyyy = 2010 ; yy = 10
; Month : MMMM = April; MMM = Apr; MM = 04; M = 4
; Day.. : dddd = Thursday; ddd = Thu; dd = 01; d = 1
; Hour. : HH = 20; H = 20 (1 digit minimum); hh = 08; h = 8 (Lowercase h's used with AM/PM time)
; Minute: mm = 05 (2 digit minimum); m = 5 (1 digit minimum)
; Second: ss = 08 (2 digit minimum); s = 8 (1 digit minimum)
; AM/PM : tt = AM or PM; t = A or P
; Ref: Format Strings @ [url="http://msdn.microsoft.com/en-us/library/bb761726%28v=VS.85%29.aspx#dtp_format_chars"]http://msdn.microsoft.com/en-us/library/bb761726%28v=VS.85%29.aspx#dtp_format_chars[/url]
; =============================================================================================
Func _Date_Time_Convert($sDateTime, $sDateTimeFormat, $sRetFormat = "yyyy/MM/dd HH:mm:ss")
    Local $Time, $iYear, $iMnth, $iDay, $iHour, $iMinute, $iSec, $aFormatIn, $msg
    Local $aMMM[12] = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
    $aFormatIn = StringRegExp($sDateTimeFormat, "(y+|M+|d+|H+|h+|m+|s+|t+)", 3) ;Array of format characters.
    For $i = 0 To UBound($aFormatIn) - 1
        $msg = StringLeft($aFormatIn[$i], 1)
        Select
            Case $msg = "y" ; y - Year
                If StringLen($aFormatIn[$i]) = 4 Then _
                        $iYear = StringMid($sDateTime, StringInStr($sDateTimeFormat, "yyyy"), _
                                StringLen($aFormatIn[$i])) & "/"
                If StringLen($aFormatIn[$i]) = 2 Then
                    $iYear = StringMid($sDateTime, StringInStr($sDateTimeFormat, "yy"), 2)
                    If Number($iYear) < Number(StringRight(@YEAR, 2) + 20) Then
                        $iYear = "20" & $iYear & "/"
                    Else
                        $iYear = "19" & $iYear & "/"
                    EndIf
                EndIf
            Case StringRegExp($msg, "M") ; M - Month
                If StringLen($aFormatIn[$i]) > 2 Then
                    $iMnth = StringMid($sDateTime, StringInStr($sDateTimeFormat, "MMM", 1), 3)
                    If StringLen($aFormatIn[$i]) < 3 Then _
                            $iMnth = StringMid($sDateTime, StringInStr($sDateTimeFormat, "MMM", 1) + 1, 2)
                    $sDateTime = StringRegExpReplace($sDateTime, "b(" & $iMnth & ".*?)b", $iMnth)
                    $sDateTimeFormat = StringRegExpReplace($sDateTimeFormat, "b(M{3})(M*)b", "1")
                EndIf
                If StringLen($aFormatIn[$i]) > 2 Then
                    For $j = 0 To UBound($aMMM) - 1
                        If StringLeft($iMnth, 3) = $aMMM[$j] Then $iMnth = StringRight("0" & $j + 1, 2) & "/"
                    Next
                ElseIf StringLen($aFormatIn[$i]) < 3 Then
                    $iMnth = Number(StringMid($sDateTime, StringInStr($sDateTimeFormat, "M", 1), 2))
                    If $iMnth > 9 And StringLen($aFormatIn[$i]) = 1 Then $sDateTimeFormat = _
                            StringRegExpReplace($sDateTimeFormat, "(?:b|[^M])(M)(?:b|[^M])", " MM")
                    $iMnth = StringRight("0" & $iMnth, 2) & "/"
                EndIf
            Case $msg = "d" ; d - Day
                If StringLen($aFormatIn[$i]) > 2 Then
                    $iDay = StringMid($sDateTime, StringInStr($sDateTimeFormat, "ddd", 1), 3)
                    $sDateTime = StringRegExpReplace($sDateTime, "b(" & $iDay & ".*?)b", "")
                    $sDateTimeFormat = StringRegExpReplace($sDateTimeFormat, "b(d{3})(d*)b", "")
                EndIf
                If StringLen($aFormatIn[$i]) <= 2 Then
                    $iDay = Number(StringMid($sDateTime, StringInStr($sDateTimeFormat, "d", 1), 2))
                    If $iDay > 9 And StringLen($aFormatIn[$i]) = 1 Then $sDateTimeFormat = _
                            StringRegExpReplace($sDateTimeFormat, "(?:b|[^d])(d)(?:b|[^d])", " dd")
                EndIf
                $iDay = StringRight("0" & $iDay, 2) & " "
            Case StringRegExp($msg, "(?i)h") ; H or h - Hour
                If StringInStr($sDateTimeFormat, "H", 1) Then
                    $iHour = StringRight("0" & Number(StringMid($sDateTime, _
                            StringInStr($sDateTimeFormat, "H", 1), 2)), 2)
                ElseIf StringInStr($sDateTimeFormat, "h", 1) Then
                    $iHour = Number(StringMid($sDateTime, StringInStr($sDateTimeFormat, "h", 1), 2))
                EndIf
                If StringInStr($sDateTime, "AM") And $iHour = 12 Then $iHour = 0
                If StringInStr($sDateTime, "PM") And $iHour < 12 Then $iHour += 12
                If $iHour > 9 And StringLen($aFormatIn[$i]) = 1 Then $sDateTimeFormat = _
                        StringRegExpReplace($sDateTimeFormat, "(?i)(?:b|[^h])(h)(?:b|[^h])", " hh")
                $iHour = StringRight("0" & $iHour, 2) & ":"
            Case StringRegExp($msg, "m") ; m - Minute
                If StringInStr($sDateTimeFormat, "m", 1) Then
                    $iMinute = Number(StringMid($sDateTime, StringInStr($sDateTimeFormat, "m", 1), 2))
                EndIf
                If $iMinute > 9 And StringLen($aFormatIn[$i]) = 1 Then $sDateTimeFormat = _
                        StringRegExpReplace($sDateTimeFormat, "(?:b|[^m])(m)(?:b|[^m])", " mm")
                $iMinute = StringRight("0" & $iMinute, 2) & ":"
            Case $msg = "s" ; s - Second
                If StringInStr($sDateTimeFormat, "ss") Then
                    $iSec = StringMid($sDateTime, StringInStr($sDateTimeFormat, "ss"), 2)
                EndIf
                If $iSec > 9 And StringLen($aFormatIn[$i]) = 1 Then $sDateTimeFormat = _
                        StringRegExpReplace($sDateTimeFormat, "(?:b|[^s])(s)(?:b|[^s])", " ss")
                $iSec = StringRight("0" & $iSec, 2) & ":"
        EndSelect
    Next
    ; Default values added to empty, unused variables for entry into the Date Control.
    If $iYear = "" Then $iYear = "1900/"
    If $iMnth = "" Then $iMnth = "01/"
    If $iDay = "" Then $iDay = "01 "
    If $iHour = "" Then $iHour = "00:"
    If $iMinute = "" Then $iMinute = "00:"
    If $iSec = "" Then $iSec = "00"
    $Time = $iYear & $iMnth & $iDay & $iHour & $iMinute & $iSec
    ;===== The following converts $Time to $sRetFormat format usind Date Control ======
    ; $Time is now in this format "yyyy/MM/dd HH:mm:ss"
    Local $hGui = GUICreate("My GUI get date", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate($Time, 10, 10, 185, 20)
    GUICtrlSendMsg($idDate, 0x1032, 0, $sRetFormat)
    Local $sReturn = GUICtrlRead($idDate)
    GUIDelete($hGui)
    Return $sReturn
EndFunc ;==>_Date_Time_Convert
; Open Connection to the Active Directory
Edited by bcdietz
Link to comment
Share on other sites

Check the quotes on that line, because you're missing one or 2. You should probably surround the string for the URL with single quotes so that the double quotes inside the string won't need to be doubled up.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

yeah, I edited it, to save the name of the company I work for. (security stuff)

$startURL = "http://xxxx.xxxx.com/Empl_Data/PhoneDirectory_new.jsp?lastname=" & $slname & "&firstname=" & $sfname & "&submit=Search"

It works fine, execpt it makes AD.AU3 error for some reason. (likely calls the same function or something)

I think I found out the powershell option. x64 vs x86

When I compiled the script, I unchecked the x64 option (32 bit only) but if you have the x64 version installed the x32 won't work. I verified by adding the

#AutoIt3Wrapper_UseX64=N to my script.

So, my question stand now, how do I get the script/executable to run x32 if x32 is installed, and x64 if x64 is installed?

Link to comment
Share on other sites

IIR we had a similar problem because two UDFs were used concurrently.

I think the problem was solved by running them sequentially. That means call _AD_Open, do all the AD stuff and then call _AD_Close. To call _AD_Close is important because it releases all the objects and the error handler.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Hmm...

I call the _AD_Open to pull if the user ID exists.

Could I open, pull the OU and AD User, close, pull the screen scrape from IE.AU3, then AD_Open create the user and all the trimmings, then close again?

As far as the x86 and x64. I created two .exe's one newuser.exe and another newuser64.exe both work on their respective machines. Is there a way to have one exe work on either platform?

Also, how do I have it close the window once the user is created? I originally wanted it to stay open so they could add multiple users. But it seems the script dies once I hit create user. I even commented out the exitloop and it still doesn't work a 2nd time.

Edited by bcdietz
Link to comment
Share on other sites

Could I open, pull the OU and AD User, close, pull the screen scrape from IE.AU3, then AD_Open create the user and all the trimmings, then close again?

Sure.

it still doesn't work a 2nd time.

Make sure that you reset all variables you've set during the first run. Not resetting used variables often leads to undesired results.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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...