Morteza Posted October 25, 2008 Share Posted October 25, 2008 Dear friends, On a multiuser system, how can I collect all of the system's user names under Administrator permission? Regards Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 25, 2008 Share Posted October 25, 2008 Taken from ptrex and modified a bit to default to admin. CODE#include <array.au3> ; Initialize error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $GroupPath = InputBox("List Group Members", "Enter DOMAIN/GROUP to list: ","Administrators") $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 For $oUser In $oGroup.Members $sRET &= $oUser.Name & @LF ; $sRET &= $oUser.Name & "," & $oUser.mail & "," & $oUser.telephoneNumber & "," & $oUser.facsimileTelephoneNumber & @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 Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Error Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Morteza Posted October 25, 2008 Author Share Posted October 25, 2008 Thank you very much dbzfanatic,Both for good answer and fast answer Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 25, 2008 Share Posted October 25, 2008 You're welcome, as I said I didn't write the code but I'm glad it helped. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] 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