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:
01670474
Vues:
48
>>>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
>>
>
>Thank you very much for the sample code. Although I can see that since I don't have the "security_activedirectory.vcx", I will have to create it, somehow.
>Another question, very newbie. Since the GETENV("UserName") gives you (if I understand correctly) the AD user name of the current user, what is the purpose of getting the loActiveDomainUser?

That is because if you are not in the domain, you also get a username. So the process gets the username, and by getting the domain user I verify if we are at all connected to the AD. Also I query the other properties that are helpful.

One thing I had problems with at one time was that there can be more than one domain. Not sure how that was setup, but they had a separate for Exchange I believe.
Christian Isberner
Software Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform