swalsh19 Posted October 29, 2008 Share Posted October 29, 2008 I have a tool created that will create users in AD. Is it possible to do the following:- automatically add a distribution group to the user upon creation- automatically add the distribution group that corresponds to the office of the user.Here is what the gui looks like that I have. Link to comment Share on other sites More sharing options...
ptrex Posted October 29, 2008 Share Posted October 29, 2008 @swalsh19 Maybe if you show some code we can figure out what needs to be done. regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
archgriffin Posted October 29, 2008 Share Posted October 29, 2008 If you use the ADfunctions you could use ADAddUserToGroup for adding users to groups. "Human kind cannot gain anything without first giving something in return, to obtain; something of equal value must be lost."The Help File is truly your friend. Link to comment Share on other sites More sharing options...
swalsh19 Posted October 30, 2008 Author Share Posted October 30, 2008 (edited) erased as it posted twice. Edited October 30, 2008 by swalsh19 Link to comment Share on other sites More sharing options...
swalsh19 Posted October 30, 2008 Author Share Posted October 30, 2008 Here is the code I have..... ; example 1 include <GUIConstants.au3> GUICreate("Filogix New User Creation",500,200) ; will create a dialog box that when displayed is centered $FirstName = GUICtrlCreateInput("",70,5,200,20) GUICtrlCreateLabel ("First Name",10,9,50,20) $LastName = GUICtrlCreateInput("",70,40,200,20) GUICtrlCreateLabel ("Last Name",10,42,55,20) $Office = GUICtrlCreateCombo ("",340,5,100,20) GUICtrlSetData(-1,"London Office|Toronto Office|Calgary Office","London Office") GUICtrlCreateLabel ("Office",305,9,30,20) $Extension = GUICtrlCreateInput("",340,40,55,20) GUICtrlCreateLabel ("Extension",287,42,50,20) $Title = GUICtrlCreateInput("",70,75,200,20) GUICtrlCreateLabel ("Title",40,77,25,20) $Department = GUICtrlCreateInput("",70,110,200,20) GUICtrlCreateLabel ("Department",7,112,55,20) $CreateUser = GUICtrlCreateButton("Create User", 70,140,70,30,$BS_DEFPUSHBUTTON) $Clear = GUICtrlCreateButton("Clear",150,140,70,30,$BS_DEFPUSHBUTTON) $Exit = GUICtrlCreateButton("Exit",230,140,70,30,$BS_DEFPUSHBUTTON) GUISetState (@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Clear Call ("Clear") Case $msg = $CreateUser Call ("CreateUser") Case $msg = $Exit Exit EndSelect WEnd Func CreateUser() $FirstState = GUICtrlRead($Firstname) $LastState = GUICtrlRead($Lastname) $OfficeState = GUICtrlRead($Office) $ExtensionState = GUICtrlRead($Extension) $TitleState = GUICtrlRead($Title) $DepartmentState = GUICtrlRead($Department) If $FirstState = "" Then Msgbox (0,"First Name","Please enter a First Name") EndIf If $LastState = "" Then MsgBox (0,"Last Name", "Please enter a Last Name") EndIf If $TitleState = "" Then MsgBox (0,"Title", "Please enter the user Title") EndIf If $DepartmentState = "" Then MsgBox (0,"Department", "Please enter user Department") EndIf If $ExtensionState = "" Then MsgBox (0,"Extension", "Please enter the user phone extension") Endif If $OfficeState = "London Office" Then $Phone = "(519) 649-2363" Endif If $OfficeState = "Toronto Office" Then $Phone = "(416) 360-1777" Else $Phone = "NA" Endif RunWait (@ComSpec & " /C dsadd user " & """CN="& $Firststate & "." & $LastState & ",OU=FXUsers,DC=corp,DC=filogix,DC=com"""& " -fn " & $FirstState & " -ln " & '"' & $LastState & '"' & " -display " & '"' & $FirstState & " " & $Laststate & '"' & " -office " & '"' & $Officestate & '"'& " -tel " & '"' & $Phone & '"' & "-ext " & $ExtensionState & '"' & " -title " & '"' & $TitleState & '"' & " -dept " & '"' & $DepartmentState & '"'& " -company " & """Filogix Limited Partnership""" & " -email " & $FirstState & "." & $LastState & "@filogix.com" & " -upn " & $FirstState & "." & $LastState & "@filogix.com" & " -pwd ABCD+1234 -loscr login.bat -mustchpwd yes -disabled no") EndFunc Func Clear() GuIctrlsetdata (3,"") GuIctrlsetdata (5,"") GuIctrlsetdata (9,"") GuIctrlsetdata (11,"") GuIctrlsetdata (13,"") EndFunc Link to comment Share on other sites More sharing options...
swalsh19 Posted October 30, 2008 Author Share Posted October 30, 2008 Any help is MUCH appreciated. I will look at those tools also posted. Link to comment Share on other sites More sharing options...
ptrex Posted October 30, 2008 Share Posted October 30, 2008 @swalsh19 This should get you going. You will have to put in your details and add this to you script. Const $olDistributionListItem = 7 $Set $objOutlook = ObjCreate("Outlook.Application") $Set $objList = $objOutlook.CreateItem($olDistributionListItem ) $objList.DLName = $OfficeState ; This your variable from your script !! $objList.Save ; Change it to the proper details $bjGroup = ObjGet("LDAP://CN=Finance Users,OU=Finance,,DC=fabrikam,DC=com") For $strUser in $objGroup.Member $objUser = ObjGet("LDAP://" & $strUser) $strUserName = $objUser.displayName $objRecipient = $objOutlook.Session.CreateRecipient($strUserName) $objRecipient.Resolve $objList.AddMember ($objRecipient) Next Play around with this to see what it does Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
swalsh19 Posted October 30, 2008 Author Share Posted October 30, 2008 Thanks for this I appreciate it. I'm very NEW to all this and was taking the code a previous employee used and editing it. I will play with the snipet you gave me, but if you have a chance can you maybe put some comments beside the areas I need to edit to match my AD config? Link to comment Share on other sites More sharing options...
swalsh19 Posted October 30, 2008 Author Share Posted October 30, 2008 (edited) Is only the one line needed to be changed from: $bjGroup = ObjGet("LDAP://CN=Finance Users,OU=Finance,,DC=fabrikam,DC=com") TO this: $bjGroup = ObjGet("LDAP://"""CN="& $Firststate & "." & $LastState & ",OU=FXUsers,DC=corp,DC=filogix,DC=com"""") Is that syntax for that line correct? Just a little unclear as to where I would be putting in the name of the distribution group I want added for all users.... I also am getting a compile error with the original code I posted when I try to compile it. Edited October 30, 2008 by swalsh19 Link to comment Share on other sites More sharing options...
swalsh19 Posted October 30, 2008 Author Share Posted October 30, 2008 I think my syntax is wrong for that line above. Mind you when I try to compile I get an error before that line anyways so I'm not sure... Link to comment Share on other sites More sharing options...
swalsh19 Posted October 31, 2008 Author Share Posted October 31, 2008 I appreciate the info ptrex has given me. Can anyone see what it is I have wrong on the line above> Link to comment Share on other sites More sharing options...
swalsh19 Posted November 2, 2008 Author Share Posted November 2, 2008 (edited) ANyone see what I'm doing wrong? For some reason the original code that currently is working as I'm using the application won't even compile. AM I missing something in my system> Edited November 2, 2008 by swalsh19 Link to comment Share on other sites More sharing options...
Valuater Posted November 2, 2008 Share Posted November 2, 2008 I use a message box to test code... try this it is not correct MsgBox(0x0, "", "LDAP://"""CN="& $Firststate & "." & $LastState & ",OU=FXUsers,DC=corp,DC=filogix,DC=com"""") 8) 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