GELÖSCHT
Verfasst: 27.01.2012 23:19
GELÖSCHT
Code: Alles auswählen
NetGroupGetUsers_(@ServerName.s, @GroupName.s, Level.l, @*Buffer, PrefMaxLen.l, @EntiersRead.l, @TotelEntries.l, @*Handle)
Code: Alles auswählen
Structure GROUP_USERS_INFO_0
grui0_name.s
EndStructure
Structure GROUP_USERS_INFO_1
grui1_name.s
grui1_attributes.l
EndStructure
*Buffer.GROUP_USERS_INFO_1
Define Handle = 0
error = NetGroupGetUsers_(ServerName.s, GroupName.s, 1, @*Buffer, PrefMaxLen.l, @EntiersRead.l, @TotelEntries.l, @Handle)
Code: Alles auswählen
Import "netapi32.lib"
NetGroupEnum(servername.p-unicode, level.l, *burptr, prefmaxlen.l, *entriesread.l, *totalentries.l, *resumehanle.l)
NetGroupEnum_local(null, level.l, *burptr, prefmaxlen.l, *entriesread.l, *totalentries.l, *resumehanle.l) As "_NetGroupEnum"
NetGroupGetUsers(servername.p-unicode, groupname.p-unicode, level.l, *bufptr, prefmaxlen.l, *entriesread.l, *totalentries, *resumehandle.i)
NetGroupGetUsers_local(null, groupname.p-unicode, level.l, *bufptr, prefmaxlen.l, *entriesread.l, *totalentries, *resumehandle.i) As "_NetGroupGetUsers"
EndImport
#MAX_PREFERRED_LENGTH = $FFFFFFF
Structure GROUP_INFO_0
*grpi0_name.i
EndStructure
Structure GROUP_INFO
info.GROUP_INFO_0[0]
EndStructure
Structure GROUP_USERS_INFO_0
*grui0_name.i
EndStructure
Structure GROUP_USERS_INFO
info.GROUP_USERS_INFO_0[0]
EndStructure
Procedure EnumGroupsAndUsers()
Protected *group.GROUP_INFO
Protected resume_handle.i = 0;
Protected entries_read.i
Protected totalentries.i
While NetGroupEnum_local(0, 1, @*group, #MAX_PREFERRED_LENGTH, @entries_read.i, @totalentries.i, @resume_handle) = 0
Protected group.i
For group = 0 To entries_read - 1
Protected groupname.s = PeekS(*group\info[group]\grpi0_name, -1, #PB_Unicode)
Debug "Group: " + groupname
Protected *user.GROUP_USERS_INFO
Protected resume_handle2.i = 0
Protected entries_read2.i
Protected totalentries2.i
While NetGroupGetUsers_local(0, groupname, 0, @*user, #MAX_PREFERRED_LENGTH, @entries_read2.i, @totalentries2.i, @resume_handle2) = 0
Protected user
For user = 0 To entries_read2 - 1
Debug " User: " + PeekS(*user\info[user]\grui0_name, -1, #PB_Unicode)
Next
NetApiBufferFree_(*user)
If resume_handle2 = 0
Break
EndIf
Wend
Next
NetApiBufferFree_(*group)
If resume_handle = 0
Break
EndIf
Wend
EndProcedure
EnumGroupsAndUsers()
Code: Alles auswählen
Macro DEFINE_GUID(Name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Global Name.GUID
Name\Data1 = l
Name\Data2 = w1
Name\Data3 = w2
Name\Data4[0] = b1
Name\Data4[1] = b2
Name\Data4[2] = b3
Name\Data4[3] = b4
Name\Data4[4] = b5
Name\Data4[5] = b6
Name\Data4[6] = b7
Name\Data4[7] = b8
EndMacro
DEFINE_GUID(IID_IDsObjectPicker, $0c87e64e, $3b7a, $11d2, $b9, $e0, $00, $c0, $4f, $d8, $db, $f7)
DEFINE_GUID(CLSID_DsObjectPicker, $17d6ccd8, $3b7b, $11d2, $b9, $e0, $00, $c0, $4f, $d8, $db, $f7)
Structure DSOP_UPLEVEL_FILTER_FLAGS
flBothModes.i
flMixedModeOnly.i
flNativeModeOnly.i
EndStructure
Structure DSOP_FILTER_FLAGS
Uplevel.DSOP_UPLEVEL_FILTER_FLAGS
flDownlevel.i
EndStructure
Structure DSOP_SCOPE_INIT_INFO
cbSize.i
flType.i
flScope.i
FilterFlags.DSOP_FILTER_FLAGS
*pwzDcName.i ;pointer to unicode string
*pwzADsPath.i ;pointer to unicode string
hr.i
EndStructure
Structure DSOP_INIT_INFO
cbSize.i
*pwzTargetComputer.i ;pointer to unicode string
cDsScopeInfos.i
*aDsScopeInfos.DSOP_SCOPE_INIT_INFO
flOptions.i
cAttributesToFetch.i
*apwzAttributeNames.i ;pointer to unicode string
EndStructure
Interface IDsObjectPicker Extends IUnknown
Initialize(*pInitInfo.DSOP_INIT_INFO);
InvokeDialog(hwndParent.i, *ppdoSelections);
EndInterface
Structure DS_SELECTION
*pwzName.i ;unicode strings
*pwzADsPath.i
*pwzClass.i
*pwzUPN.i
*pvarFetchedAttributes.VARIANT
flScopeType.i
EndStructure
Structure DS_SELECTION_LIST
cItems.i
cFetchedAttributes.i
aDsSelection.DS_SELECTION[0]
EndStructure
#CLSCTX_INPROC_SERVER = 1
#DSOP_SCOPE_TYPE_TARGET_COMPUTER = $1
#DSOP_SCOPE_TYPE_GLOBAL_CATALOG = $10
;more http://msdn.microsoft.com/en-us/library/windows/desktop/ms676014(v=vs.85).aspx
#DSOP_DOWNLEVEL_FILTER_USERS = $80000001
#DSOP_DOWNLEVEL_FILTER_LOCAL_GROUPS = $80000002
#DSOP_DOWNLEVEL_FILTER_GLOBAL_GROUPS = $80000004
;more http://msdn.microsoft.com/en-us/library/windows/desktop/ms676012(v=vs.85).aspx
Procedure ShowDialog()
Protected *Dialog.IDsObjectPicker
Protected Hr.i = CoInitialize_(0)
If Hr = #S_OK Or Hr = #S_FALSE ;returns False if it was allready loaded
If CoCreateInstance_(@CLSID_DsObjectPicker, 0, #CLSCTX_INPROC_SERVER, @IID_IDsObjectPicker, @*Dialog) = #S_OK
ScopeInfo.DSOP_SCOPE_INIT_INFO
ScopeInfo\cbSize = SizeOf(DSOP_SCOPE_INIT_INFO)
ScopeInfo\flType = #DSOP_SCOPE_TYPE_GLOBAL_CATALOG | #DSOP_SCOPE_TYPE_TARGET_COMPUTER
ScopeInfo\flScope = 0
ScopeInfo\FilterFlags\flDownlevel = #DSOP_DOWNLEVEL_FILTER_LOCAL_GROUPS | #DSOP_DOWNLEVEL_FILTER_USERS | #DSOP_DOWNLEVEL_FILTER_GLOBAL_GROUPS
;use this to Select what kind of information should be filtered
ScopeInfo\pwzDcName = 0
ScopeInfo\pwzADsPath = 0
Info.DSOP_INIT_INFO
Info\cbSize = SizeOf(DSOP_INIT_INFO)
Info\pwzTargetComputer = 0 ;local
Info\cDsScopeInfos = 1
Info\aDsScopeInfos = @ScopeInfo
Info\flOptions = 0
Info\cAttributesToFetch = 0
Info\apwzAttributeNames = 0
If *Dialog\Initialize(Info) = #S_OK
*Objects.IDataObject
;Hwnd cannot be NULL, works in XP, but Vista fails
If *Dialog\InvokeDialog(WindowID(0), @*Objects) = #S_OK
Protected stm.STGMEDIUM
Protected fe.FORMATETC
fe\cfFormat = RegisterClipboardFormat_("CFSTR_DSOP_DS_SELECTION_LIST");
fe\dwAspect = 1
fe\lindex = -1
fe\tymed = 1
If *Objects\GetData(@fe, @stm) = #S_OK
Protected *List.DS_SELECTION_LIST = GlobalLock_(stm\hGlobal);
If *List
Protected i.i
For i = 0 To *List\cItems - 1
AddGadgetItem(2, -1, "Object Nr. " + Str(i))
AddGadgetItem(2, -1, " Name: " + PeekS(*List\aDsSelection[i]\pwzName, -1, #PB_Unicode))
AddGadgetItem(2, -1, " Class: " + PeekS(*List\aDsSelection[i]\pwzClass, -1, #PB_Unicode))
AddGadgetItem(2, -1, " Path: " + PeekS(*List\aDsSelection[i]\pwzADsPath, -1, #PB_Unicode))
AddGadgetItem(2, -1, " UPN: " + PeekS(*List\aDsSelection[i]\pwzUPN, -1, #PB_Unicode))
Next
GlobalUnlock_(stm\hGlobal)
EndIf
ReleaseStgMedium_(@stm)
EndIf
*Objects\Release()
EndIf
EndIf
*Dialog\Release()
EndIf
If Hr = #S_OK ;if we loaded it, we free it again
CoUninitialize_()
EndIf
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 400, 300, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(1, 5, 5, 100, 20, "Select")
ListViewGadget(2, 5, 25, 390, 270)
Define Event
Repeat
Event = WaitWindowEvent(0)
If Event = #PB_Event_Gadget
If EventGadget() = 1
ClearGadgetItems(2)
ShowDialog()
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf