Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to determine that the User has Admin privileges
Message
De
20/10/2004 10:47:44
 
 
À
19/10/2004 15:25:03
Nitin Parulekar
New Zealand Software Corp Ltd
Hamilton, Nouvelle Zélande
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00824487
Message ID:
00953013
Vues:
31
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform