EarleKelley Posted May 15, 2007 Share Posted May 15, 2007 HELP! I am fairly new to the advanced features of AutoIt. I have used it to automate some Software installs, perform Password changes (using the SEND command), etc. I have now been charged with writing a script that will: 1. Generate a list of users in a group in Active Directory 2. For each user in that group, use the "net send" dos command to send a specific broadcast message. I think I can handle the second part of this (as I have used AutoIt to perform DOS functions, and have used for...next loops). I just need help with the first part. We have different groups set up for different departments. We would like to be able to send a broadcast message to one specific group. Can anyone help me? Thanks in advance. Link to comment Share on other sites More sharing options...
herewasplato Posted May 15, 2007 Share Posted May 15, 2007 Welcome to the forum.Take a look at:http://www.autoitscript.com/forum/index.ph...st&p=144056andhttp://www.autoitscript.com/forum/index.ph...st&p=201634Caveat: I've not used either script.-MSP- [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
EarleKelley Posted May 16, 2007 Author Share Posted May 16, 2007 Welcome to the forum.Take a look at:http://www.autoitscript.com/forum/index.ph...st&p=144056andhttp://www.autoitscript.com/forum/index.ph...st&p=201634Caveat: I've not used either script.-MSP-Thanks HereWasPlato...I checked both of these out, and the second one will not help me, as it is asking for the username... I need to automatically fetch the name from a group. The first script seemed promising. I may have been able to use part of it, however, I do not speak French, and cannot make out what he is trying to do... Here is the pseudo code for the entire script I have in mind...***************************************************************GET MESSAGE TEXT$Message = Inputbox(MESSAGE)GET USERID from AD Group <<This is what I don't know how to do...>>For Each USERID do $Username = LANID from ActiveDirectory RUN COMMAND LINE : net send $Username $MessageNext***************************************************************I may have to try creating a VB script... (although I would have to learn VBS first...) Link to comment Share on other sites More sharing options...
ptrex Posted May 16, 2007 Share Posted May 16, 2007 @EarleKelley Maybe this can help you out. $objGroup = ObjGet("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com") $objGroup.GetInfo $arrMemberOf = $objGroup.GetEx("member") ConsoleWrite ("Members:") For $strMember in $arrMemberOf ConsoleWrite( $strMember & @CRLF & @CRLF) Next 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...
nitekram Posted May 16, 2007 Share Posted May 16, 2007 (edited) @EarleKelley Maybe this can help you out. $objGroup = ObjGet("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com") $objGroup.GetInfo $arrMemberOf = $objGroup.GetEx("member") ConsoleWrite ("Members:") For $strMember in $arrMemberOf ConsoleWrite( $strMember & @CRLF & @CRLF) Next Regards ptrexHow do you run this against the server or do you need to run it on the server - by the way I like the Exchange script that you did, but that too had to be ran on the server. Maybe a permission issue? EDIT Actually - I get an error on second line $objGroup.GetInfo - maybe issue with server name? Edited May 16, 2007 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow."  WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI  CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Developers Jos Posted May 16, 2007 Developers Share Posted May 16, 2007 (edited) How do you run this against the server or do you need to run it on the server - by the way I like the Exchange script that you did, but that too had to be ran on the server. Maybe a permission issue?This will work on your own pc as long as you are logged-on in the domain and have admin rights. Edited May 16, 2007 by JdeB SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
nitekram Posted May 16, 2007 Share Posted May 16, 2007 This will work on your own pc as long as you are logged-on in the domain and have admin rights.I get this>Running:(3.2.2.0):C:\Program Files\AutoIt3\autoit3.exe "Z:\New 251507\user_list_AD.au3" Z:\New 251507\user_list_AD.au3 (6) : ==> Variable must be of type "Object".: $objGroup.GetInfo $objGroup^ ERROReither running it on the server or work station - admin account on both 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow."  WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI  CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Developers Jos Posted May 16, 2007 Developers Share Posted May 16, 2007 I get this>Running:(3.2.2.0):C:\Program Files\AutoIt3\autoit3.exe "Z:\New 251507\user_list_AD.au3" Z:\New 251507\user_list_AD.au3 (6) : ==> Variable must be of type "Object".: $objGroup.GetInfo $objGroup^ ERROReither running it on the server or work station - admin account on bothYou are sure you specified the correct domain information on the first line ? SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 16, 2007 Share Posted May 16, 2007 (edited) For your group-listing pleasure: expandcollapse popup#include <array.au3> $GroupPath = InputBox("List Group Members", "Enter DOMAIN/GROUP to list: ") $avUsers = _GroupGetMembers($GroupPath) If Not @error Then _ArrayDisplay($avUsers, "Users in group") Else MsgBox(16, "Error", "Error returned: @error = " & @error) EndIf ; ------------------------------------------------------------ ; Function _GroupGetMembers($sPath) ; Call with: _GroupGetMembers($sPath) ; Where: $sPath = DOMAIN/GROUP, i.e. "MyDomain/Domain Admins" ; If Domain is not included, uses local machine, i.e. "Administrators" will be xlated to "./Administrators" ; On success returns an array of members in the specified group with [0] = count. ; For an empty group, returns [0] = 0. ; On failure sets @error. ; ------------------------------------------------------------ Func _GroupGetMembers($sPath) Local $oUser, $sRET = "", $avRET ; Check path to group $sPath = StringReplace($sPath, "\", "/") ; Don't use backslash with WMI path If Not StringInStr($sPath, "/") Then $sPath = "./" & $sPath ; Use local if no domain given ; Get group object Local $oGroup = ObjGet("WinNT://" & $sPath) If IsObj($oGroup) Then ; List users in group For $oUser In $oGroup.Members $sRET &= $oUser.Name & @LF Next ; Split into an array for return $avRET = StringSplit(StringStripWS($sRET, 2), @LF) ; Change result for empty group [0] = 0 If $avRET[1] = "" Then Local $avRET[1] = [0] Return $avRET Else ; Error getting group object Return SetError(1, 0, 0) EndIf EndFunc ;==>_GroupGetMembers Edited May 16, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
nitekram Posted May 16, 2007 Share Posted May 16, 2007 (edited) You are sure you specified the correct domain information on the first line ?I did not do that - can you explain what I need to change - sorry all I know is that DC is domain controller - right?Edit "LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com"1147 05/16/07Found some more info - I was wrong ... WOW ... like that will never happen againDC is domain component If an organization has domain name foo.example, its top level LDAP entry will therefore typically have the DN dc=foo,dc=example (where dc means domain component). Edited May 17, 2007 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow."  WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI  CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Zedna Posted May 16, 2007 Share Posted May 16, 2007 Look at my NET SEND GUII'm using NET VIEW to list active users in domain Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
EarleKelley Posted May 17, 2007 Author Share Posted May 17, 2007 For your group-listing pleasure: expandcollapse popup#include <array.au3> $GroupPath = InputBox("List Group Members", "Enter DOMAIN/GROUP to list: ") $avUsers = _GroupGetMembers($GroupPath) If Not @error Then _ArrayDisplay($avUsers, "Users in group") Else MsgBox(16, "Error", "Error returned: @error = " & @error) EndIf ; ------------------------------------------------------------ ; Function _GroupGetMembers($sPath) ; Call with: _GroupGetMembers($sPath) ; Where: $sPath = DOMAIN/GROUP, i.e. "MyDomain/Domain Admins" ; If Domain is not included, uses local machine, i.e. "Administrators" will be xlated to "./Administrators" ; On success returns an array of members in the specified group with [0] = count. ; For an empty group, returns [0] = 0. ; On failure sets @error. ; ------------------------------------------------------------ Func _GroupGetMembers($sPath) Local $oUser, $sRET = "", $avRET ; Check path to group $sPath = StringReplace($sPath, "\", "/") ; Don't use backslash with WMI path If Not StringInStr($sPath, "/") Then $sPath = "./" & $sPath ; Use local if no domain given ; Get group object Local $oGroup = ObjGet("WinNT://" & $sPath) If IsObj($oGroup) Then ; List users in group For $oUser In $oGroup.Members $sRET &= $oUser.Name & @LF Next ; Split into an array for return $avRET = StringSplit(StringStripWS($sRET, 2), @LF) ; Change result for empty group [0] = 0 If $avRET[1] = "" Then Local $avRET[1] = [0] Return $avRET Else ; Error getting group object Return SetError(1, 0, 0) EndIf EndFunc ;==>_GroupGetMembers Thanks PasltyDS.... This worked! Zedna, I will check yous out in a bit.. Thanks all for your help! Link to comment Share on other sites More sharing options...
Xenocide Posted September 28, 2007 Share Posted September 28, 2007 Thanks PasltyDS.... This worked! Zedna, I will check yous out in a bit.. Thanks all for your help!i've tried this code and while it works for some objects, some report an error. we use a NDS tree that replicates to the AD. Preferably i would like to query the NDS but, the AD should return the results needed. can any one explain why i'm not getting consistent results and perhaps provide a way around the problem.the objects i'm searching are in the same container.Cheers Link to comment Share on other sites More sharing options...
Rouge Posted October 1, 2008 Share Posted October 1, 2008 For your group-listing pleasure: expandcollapse popup#include <array.au3> $GroupPath = InputBox("List Group Members", "Enter DOMAIN/GROUP to list: ") $avUsers = _GroupGetMembers($GroupPath) If Not @error Then _ArrayDisplay($avUsers, "Users in group") Else MsgBox(16, "Error", "Error returned: @error = " & @error) EndIf ; ------------------------------------------------------------ ; Function _GroupGetMembers($sPath) ; Call with: _GroupGetMembers($sPath) ; Where: $sPath = DOMAIN/GROUP, i.e. "MyDomain/Domain Admins" ; If Domain is not included, uses local machine, i.e. "Administrators" will be xlated to "./Administrators" ; On success returns an array of members in the specified group with [0] = count. ; For an empty group, returns [0] = 0. ; On failure sets @error. ; ------------------------------------------------------------ Func _GroupGetMembers($sPath) Local $oUser, $sRET = "", $avRET ; Check path to group $sPath = StringReplace($sPath, "\", "/") ; Don't use backslash with WMI path If Not StringInStr($sPath, "/") Then $sPath = "./" & $sPath ; Use local if no domain given ; Get group object Local $oGroup = ObjGet("WinNT://" & $sPath) If IsObj($oGroup) Then ; List users in group For $oUser In $oGroup.Members $sRET &= $oUser.Name & @LF Next ; Split into an array for return $avRET = StringSplit(StringStripWS($sRET, 2), @LF) ; Change result for empty group [0] = 0 If $avRET[1] = "" Then Local $avRET[1] = [0] Return $avRET Else ; Error getting group object Return SetError(1, 0, 0) EndIf EndFunc ;==>_GroupGetMembers Hello PsaltyDS I like your code. I have a exchange 2007 and I would like do you know if it's possible to return value in email, phone, faxnumber and other value of AD ?? thank you Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 1, 2008 Share Posted October 1, 2008 Hello PsaltyDSI like your code.I have a exchange 2007 and I would like do you know if it's possible to return value in email, phone, faxnumber and other value of AD ??thank youOught to be $oUser.mail, $oUser.telephoneNumber, $oUser.facsimileTelephoneNumber, etc. as listed under Active Directory user properties on MSDN. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Rouge Posted October 2, 2008 Share Posted October 2, 2008 thank you , I try that Link to comment Share on other sites More sharing options...
Rouge Posted October 2, 2008 Share Posted October 2, 2008 Well, I'm don't understand why, but I changer ouser for displayname or email, and I receive allways same result. my goal, it's to make graphic with all info of user (email, street ...) expandcollapse popup#include <array.au3> $GroupPath = "agri-marche\domain users" $displayName = _GroupGetMembers($GroupPath) If Not @error Then _ArrayDisplay($displayName, "Users in group") Else MsgBox(16, "Error", "Error returned: @error = " & @error) EndIf ; ------------------------------------------------------------ ; Function _GroupGetMembers($sPath) ; Call with: _GroupGetMembers($sPath) ; Where: $sPath = DOMAIN/GROUP, i.e. "MyDomain/Domain Admins" ; If Domain is not included, uses local machine, i.e. "Administrators" will be xlated to "./Administrators" ; On success returns an array of members in the specified group with [0] = count. ; For an empty group, returns [0] = 0. ; On failure sets @error. ; ------------------------------------------------------------ Func _GroupGetMembers($sPath) Local $displayName, $sRET = "", $avRET ; Check path to group $sPath = StringReplace($sPath, "\", "/"); Don't use backslash with WMI path If Not StringInStr($sPath, "/") Then $sPath = "./" & $sPath; Use local if no domain given ; Get group object Local $oGroup = ObjGet("WinNT://" & $sPath) If IsObj($oGroup) Then ; List users in group For $displayName In $oGroup.Members $sRET &= $displayName.Name & @LF Next ; Split into an array for return $avRET = StringSplit(StringStripWS($sRET, 2), @LF) ; Change result for empty group [0] = 0 If $avRET[1] = "" Then Local $avRET[1] = [0] Return $avRET Else ; Error getting group object Return SetError(1, 0, 0) EndIf EndFunc ;==>_GroupGetMembers Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 2, 2008 Share Posted October 2, 2008 Well, I'm don't understand why, but I changer ouser for displayname or email, and I receive allways same result. my goal, it's to make graphic with all info of user (email, street ...) Not sure what you thought was going to be different just by changing the name of the variable. What I meant was more like: ; Get group object Local $oGroup = ObjGet("WinNT://" & $sPath) If IsObj($oGroup) Then ; List users in group For $oUser In $oGroup.Members $sRET &= $oUser.Name & "," & $oUser.mail & "," & $oUser.telephoneNumber & "," & $oUser.facsimileTelephoneNumber & @LF Next Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
dreniarb Posted December 3, 2008 Share Posted December 3, 2008 Not sure what you thought was going to be different just by changing the name of the variable. What I meant was more like: ; Get group object Local $oGroup = ObjGet("WinNT://" & $sPath) If IsObj($oGroup) Then ; List users in group For $oUser In $oGroup.Members $sRET &= $oUser.Name & "," & $oUser.mail & "," & $oUser.telephoneNumber & "," & $oUser.facsimileTelephoneNumber & @LF Next When I run this, I get the following error in Scite: +>09:01:55 Starting AutoIt3Wrapper v.1.10.1.12 Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 3 CPU:X86 ANSI) >Running AU3Check (1.54.13.0) from:d:\Program Files\AutoIt3 +>09:01:55 AU3Check ended.rc:0 >Running:(3.2.12.1):d:\Program Files\AutoIt3\autoit3.exe "C:\autoit\adgrouplist.au3" C:\autoit\adgrouplist.au3 (37) : ==> The requested action with this object has failed.: $sRET &= $oUser.Name & "," & $oUser.mail & "," & $oUser.telephoneNumber & "," & $oUser.facsimileTelephoneNumber & @LF $sRET &= $oUser.Name & "," & $oUser.mail ^ ERROR ->09:01:55 AutoIT3.exe ended.rc:1 +>09:01:56 AutoIt3Wrapper Finished >Exit code: 1 Time: 1.661 checking with ldap browser, I see the proper terms are being used (ie. .name, .mail, .telephonenumber), but .name is the only one that works. Any ideas? Thanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 3, 2008 Share Posted December 3, 2008 (edited) When I run this, I get the following error in Scite: +>09:01:55 Starting AutoIt3Wrapper v.1.10.1.12 Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 3 CPU:X86 ANSI) >Running AU3Check (1.54.13.0) from:d:\Program Files\AutoIt3 +>09:01:55 AU3Check ended.rc:0 >Running:(3.2.12.1):d:\Program Files\AutoIt3\autoit3.exe "C:\autoit\adgrouplist.au3" C:\autoit\adgrouplist.au3 (37) : ==> The requested action with this object has failed.: $sRET &= $oUser.Name & "," & $oUser.mail & "," & $oUser.telephoneNumber & "," & $oUser.facsimileTelephoneNumber & @LF $sRET &= $oUser.Name & "," & $oUser.mail ^ ERROR ->09:01:55 AutoIT3.exe ended.rc:1 +>09:01:56 AutoIt3Wrapper Finished >Exit code: 1 Time: 1.661 checking with ldap browser, I see the proper terms are being used (ie. .name, .mail, .telephonenumber), but .name is the only one that works. Any ideas? Thanks Add a COM error handler and see what the exact error is when it fails. I'm thinking some properties may require more rights than others, and you may get access denied to more personal information. P.S. In the future, just start a new topic for your issue. Reopening old topics with new questions just makes it harder for people to find answers with a search. There is no marginal cost for new topics! Edited December 3, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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