Tech Tip: Obtaining a user ID
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: August 14, 2002
Compatibility: 6.7.x and 6.8.x
Here is a simple project method that will allow you to obtain the user ID for a specific user. To execute this method, call it with the name of the user as a text parameter. The method will return the user ID if the username exists in the database. Otherwise, it will return 0.
` Project Method: GetUserID
` Description: Return the user ID if the given username exists
` Return 0 otherwise
` $1 - Username
C_LONGINT($0;$UserID)
C_TEXT($1;$Uname)
$Uname:=$1
ARRAY TEXT(userNames;0)
ARRAY LONGINT(userNumbers;0)
GET USER LIST(userNames;userNumbers)
$UserID:=Find in array(userNames;$Uname)
If ($UserID#-1)
$0:=userNumbers{$UserID}
Else
$0:=0
End if