Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to determine that the User has Admin privileges
Message
From
20/10/2004 10:47:44
 
 
To
19/10/2004 15:25:03
Nitin Parulekar
New Zealand Software Corp Ltd
Hamilton, New Zealand
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00824487
Message ID:
00953013
Views:
30
Hi Nitin,
----Do you have the code for the domain user?
The function "GetUsrPriv" check user in the domain, the problem is that funtions don't work well in VFP6 because in the code call SYS(2600) functions.

Regards,


----------------------------------------------------------------------------------------
? GetUsrPriv( "UsrName", "DomainName" )

PROCEDURE GetUsrPriv
	LPARAMETERS cUser, cDominio
	LOCAL lcUser, nPrivlevel, nDword, nRetVal 

	*|-- Function returns one of following priviledge levels.
	#DEFINE USER_PRIV_GUEST  0
	#DEFINE USER_PRIV_USER  1
	#DEFINE USER_PRIV_ADMIN  2

	*|-- Check for NT
	IF VAL(OS(3)) < 4 OR VARTYPE(cUser)#"C" OR EMPTY(cUser)
	 RETURN -1
	ENDIF
	lcUser = cUser

	DECLARE integer NetUserGetInfo in netapi32 integer,string,integer, integer@
	DECLARE integer NetApiBufferFree in netapi32 integer
	Declare Long NetGetDCName in netapi32 String sServerName, String sDomainName, Integer @lPtr

	lcUser       = STRCONV(cUser, 5) + CHR(0)
	cDominio     = STRCONV(cDominio, 5) + CHR(0)
	ComputerName = 0

	*|--Get the computer name of a DC for the domain.
	NetGetDCName( CHR(0), cDominio, @ComputerName );

	nDword  = 0
	nRetVal =  NetUserGetInfo(ComputerName, lcUser, 2, @nDword)
	IF nRetVal # 0
		*|-- if nRetVal == 0x000008AD [ The user name could not be found.  ]
		*|-- if nRetVal == 0x00000035 [ The network path was not found.  ] 
		RETURN nRetVal
	ENDIF

	nPrivlevel = ASC(SUBSTR(SYS(2600, nDword, 100),13,1))
	NetApiBufferFree(nDword)

	RETURN nPrivlevel
ENDPROC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform