Ghost1987 Posted March 26, 2009 Author Posted March 26, 2009 Oh my GOD!!! It actually works!!! Can't believe it!!! I feel like a real programmer now!!! LOL!!! ;-) PsaltyDS thanks for the help. This script will return local group membership of specified user. #NoTrayIcon #RequireAdmin #include <Array.au3> Global $sLocalGroupNames; Receives struct with group names Global $avRET = _NetUserGetLocalGroups("Администратор") ;_ArrayDisplay($avRETURN, "Debug: $avRETURN") $sLocalGroupNames = StringTrimRight($sLocalGroupNames, 2) MsgBox(4096, "Test", $sLocalGroupNames) Func _NetUserGetLocalGroups($sUsername, $sServer = "") Local $tBufPtr = DllStructCreate("ptr") Local $ptBufPtr = DllStructGetPtr($tBufPtr) Local $tEntriesRead = DllStructCreate("dword") Local $ptEntriesRead = DllStructGetPtr($tEntriesRead) Local $tTotalEntries = DllStructCreate("dword") Local $ptTotalEntries = DllStructGetPtr($tTotalEntries) Local $aRet = DllCall("Netapi32.dll", "int", "NetUserGetLocalGroups", _ "wstr", $sServer, "wstr", $sUsername, "dword", 0, "dword", 0, "ptr", $ptBufPtr, _ "dword", -1, "ptr", $ptEntriesRead, "ptr", $ptTotalEntries) If $aRet[0] Then Return SetError(1, $aRet[0]) Local $iEntriesRead = DllStructGetData($tEntriesRead, 1) Local $pBuf = DllStructGetData($tBufPtr, 1) Local $sLocalGroupUsersInfo0 = "ptr" Local $tLocalGroupUsersInfo0 = DllStructCreate($sLocalGroupUsersInfo0) Local $zLocalGroupUsersInfo0 = DllStructGetSize($tLocalGroupUsersInfo0) Local $tGroupName For $i = 1 To $iEntriesRead $tLocalGroupUsersInfo0 = DllStructCreate($sLocalGroupUsersInfo0, $pBuf + ($i - 1) * $zLocalGroupUsersInfo0) $tLocalGroupName = DllStructCreate("wchar[256]", DllStructGetData($tLocalGroupUsersInfo0, 1)) $sLocalGroupNames &= DllStructGetData($tLocalGroupName, 1) & "; " Next DllCall("Netapi32.dll", "int", "NetApiBufferFree", "ptr", $pBuf) Return $aRet EndFunc ;==>_NetUserGetLocalGroups But I have additional question on msdn in NetUserGetLocalGroups function defention there is DWORD flags input that can be specified, and it states that only LG_INCLUDE_INDIRECT is only avaliable bit mask. How could I implement this flag in the above function? And another question can I check for correct user name and password using NetUserChangePassword()?
PsaltyDS Posted March 26, 2009 Posted March 26, 2009 (edited) Oh my GOD!!! It actually works!!! Can't believe it!!! I feel like a real programmer now!!! LOL!!! ;-) PsaltyDS thanks for the help. This script will return local group membership of specified user. But I have additional question on msdn in NetUserGetLocalGroups function defention there is DWORD flags input that can be specified, and it states that only LG_INCLUDE_INDIRECT is only avaliable bit mask. How could I implement this flag in the above function? And another question can I check for correct user name and password using NetUserChangePassword()? Just add this to the top: Global CONST $LG_INCLUDE_INDIRECT = 0x1 Make it Local vice Global if you will declare inside the function. Use $LG_INCLUDE_INDIRECT for the flags parameter value in your DLLCall(): Local $aRet = DllCall("Netapi32.dll", "int", "NetUserGetLocalGroups", _ "wstr", $sServer, _ "wstr", $sUsername, _ "dword", 0, _ "dword", $LG_INCLUDE_INDIRECT, _ "ptr", $ptBufPtr, _ "dword", -1, _ "ptr", $ptEntriesRead, _ "ptr", $ptTotalEntries) Edited March 26, 2009 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
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