Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
User Member Of
Message
From
10/02/2006 15:38:29
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01095473
Message ID:
01095553
Views:
20
>Is there anyway to determine which groups the currently logged in user belongs to Such as Administrator, Power User, Users, etc..
>
>
>Thanks
>
>Kirk

Hi Kirk
Try this
Declare Long NetApiBufferFree in NetAPI32 Long lpBuffer

Declare Long NetUserGetGroups in NetAPI32 ;
   String wServerName, String wUserName, Long nLevel, ;
   Long @lpBuffer, Long @nMaxBufLen, Long @nEntriesRead, Long @nTotal

Declare Long NetUserGetLocalGroups in NetAPI32 ;
   String wServerName, String wUserName, Long nLevel, Long nFlags, ;
   Long @lpBuffer, Long @nMaxBufLen, Long @nEntriesRead, Long @nTotal

Declare Integer lstrlenW in Kernel32 as GetStrLenW Long lpString
Declare Long RtlMoveMemory in Kernel32 as CopyMem2Num ;
   Long @nDest, Long lpSource, Long nLength

Store 0 to pBuffer, nEntries, nTotal
* wServerName = strconv(strconv( '\\TheServer'+chr(0), 1), 5)
wServerName = Null  && local computer
wUserName = strconv(strconv( GetEnv( 'UserName' )+chr(0), 1), 5)

***  Try this for Server
*   nStatus = NetUserGetGroups( wServerName, wUserName, 0, ;
*      @pBuffer, -1, @nEntries, @nTotal )

nStatus = NetUserGetLocalGroups( wServerName, wUserName, 0, 0, ;
   @pBuffer, -1, @nEntries, @nTotal )

If (nStatus == 0) and (nEntries > 0)
   pGroupName = 0
   For nI = 0 to nEntries-1
      CopyMem2Num( @pGroupName, pBuffer + (4*nI), 4 )
      nLen = GetStrLenW( pGroupName ) * 2
      ? 'GroupName: ' + strconv(strconv( sys( 2600, pGroupName, nLen ), 6), 2)
   Next
endif

If (pBuffer != 0)
   NetApiBufferFree( pBuffer )
endif
HTH
Herman
Previous
Reply
Map
View

Click here to load this message in the networking platform