Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Active Directory
Message
 
 
Information générale
Forum:
Windows
Catégorie:
Informatique en général
Divers
Thread ID:
01670340
Message ID:
01670469
Vues:
41
>Hello,
>
>Does anyone know what information VFP 9 can query from the Windows environment with regards to the user logged into the PC (I assume they log using their AD credentials). For example,
>SYS(0) - User Name
>Are there other SYS settings in VFP 9 that can get the user email and/or ID? Other information?
>
>TIA

This is a method in my domainuserinfo class, GetDomainuserInfo(). it returns an object ADUser which is a class with the necessary properties that you want to use.
LPARAMETERS tcUserName, tcUserDomain
*
#DEFINE ADS_NAME_INITTYPE_GC  3
#DEFINE ADS_NAME_TYPE_NT4 	3
#DEFINE ADS_NAME_TYPE_1779 	1
*
LOCAL lcCurrentUserName, lcCurrentUserDomain
lcCurrentUserName = GETENV("UserName")
lcCurrentUserDomain = GETENV("UserDomain")
*
*-- If parameters are not supplied, use current user login info
LOCAL lcUserName, lcUserDomain
lcUserName = EVL(tcUserName, lcCurrentUserName)
lcUserDomain = EVL(tcUserDomain, lcCurrentUserDomain)
*
LOCAL loNameTrans, lcDN
LOCAL loActiveDomainUser
*
LOCAL loADUser AS Aduser OF security_activedirectory.vcx
loADUser = MakeObject("Aduser","security_activedirectory.vcx")
*
TRY

	*-- Use NameTranslate object to get DN based on Windows Login Name
	loNameTrans = CREATEOBJECT("NameTranslate")					
	loNameTrans.Init( ADS_NAME_INITTYPE_GC, "")
	loNameTrans.Set(ADS_NAME_TYPE_NT4, lcUserDomain + "\" + lcUserName)
	lcDN = loNameTrans.Get(ADS_NAME_TYPE_1779)
	loActiveDomainUser = GETOBJECT("LDAP://" + lcDN)
	loADUser.Exists = .T.
	loADUser.DomainName = lcDN
	loADUser.FullName = loActiveDomainUser.cn
	loADUser.Department = loActiveDomainUser.Department
	loADUser.PrincipalName = loActiveDomainUser.UserPrincipalName
	loADUser.DistinguishedName = loActiveDomainUser.DistinguishedName
	loADUser.CurrentUserDomain = lcUserDomain
CATCH TO oExp WHEN oExp.Errorno = 1426
	loActiveDomainUser = Null
	loADUser.Exists = .F.
ENDTRY	
*
RETURN loADUser
Christian Isberner
Software Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform