How do I get the user's full name?
I have the following code in VBS that works great. it asks AD to get the full username:
Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
strFullName = objUser.Get("displayName")
MsgBox strFullName
I would love to do the same, but in Foxpro 7. Anyone have any experience with VFP 7 or 9?
+3
source to share
4 answers
Ok, it looks like the stuff is pretty old ... and it's true!;) I found a solution, but it might help someone, someday, someday :)
loScript = Createobject("MSScriptcontrol.scriptcontrol.1")
loScript.Language = "VBScript"
TESTVBS = [Set objSysInfo = CreateObject("ADSystemInfo")] + chr(13)+chr(10)+;
[strUser = objSysInfo.UserName] + chr(13)+chr(10)+;
[Set objUser = GetObject("LDAP://" & strUser)] + chr(13)+chr(10)+;
[strFullName = objUser.Get("displayName")] + chr(13)+chr(10)
*[MsgBox strFullName]
loScript.executestatement(TESTVBS)
this is how you execute VBS from Foxpro code ... two technologies that are no longer technologies :)
+2
source to share
I am using this function:
FUNCTION Get_User()
LOCAL cUsrBuf, nUsrLen, cUserName
cUsrBuf = SPACE(20)
nUsrLen = 20
DECLARE GetUserName IN advapi32 AS GetUserName STRING @cusrbuf, LONG @nusrlen
=GetUserName(@cusrbuf, @nusrlen)
cUserName = LEFT(ALLTRIM(cusrbuf), LEN(ALLTRIM(cusrbuf)) - 1)
RETURN cUserName
ENDFUNC
I would not use SYS (0) because: SYS (0) returns 1 when using Visual FoxPro offline
Only when the machine is online does SYS (0) return the machine name, a space, a number sign (#), followed by another space, and then the ID of the current user (or the security context in which Visual FoxPro is running).
0
source to share