Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get the full user's name of the PC
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01406221
Message ID:
01406699
Views:
91
This message has been marked as a message which has helped to the initial question of the thread.
>It's a computer in the network, but I don't know what we're using here.

As trying is easy, we can assume you are in a domain and using LDAP, so you can try this code, note that this is an old test I've done long time ago and never used it other than for testing, so there is no error checking
#define	ADS_NAME_INITTYPE_GC	3
#define	ADS_NAME_TYPE_1779		1
#define	ADS_NAME_TYPE_NT4		3
clear

loUser			= GetObject("LDAP://" + getDistinguishedName(Getenv("USERNAME")))
? loUser.CN

Function getDistinguishedName(tcSAMAccountName, tcDomain)
	local loNameTranslate, lcDistinguishedName, lcDomain
 
 	lcDomain			= Iif(Vartype(tcDomain) = 'C' and not Empty(tcDomain), tcDomain, Getenv("USERDOMAIN"))
	loNameTranslate			= CreateObject("NameTranslate", ADS_NAME_INITTYPE_GC, "")
 	loNameTranslate.Set(ADS_NAME_TYPE_NT4, lcDomain + "\" + tcSAMAccountName)
	lcDistinguishedName		= loNameTranslate.Get(ADS_NAME_TYPE_1779)
	return lcDistinguishedName
endfunc
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform