Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ID() function - works differently Novell vs. Windows servers?

Status
Not open for further replies.

dbMark

Programmer
Apr 10, 2003
1,515
US
Under Novell 5, the dBase 5 function ID() would return the user's login name in uppercase and with "1" appended. Then we switched to Windows 2000 server, but now ID() only retrieve's the workstation's ID (all in uppercase and still with "1" appended) rather than the user's ID, which has obvious security implications. Is there a way to get the user's name from the Windows server or login so that ID() works again? If not, then my last resort is to somehow create a SET environment variable at login that we can read with a UDF.

We use a workstation mixture of Win98,Me,2000,XP.

Before with Novell:

login: John
ID(): JOHN1

After with Windows 2000:

workstation ID: John-wkstn
ID(): JOHN-WKSTN1

I know in Visual FoxPro the ID() or SYS(0) functions return both the workstation and username in one string, but we still use dBase a lot!
 
extern clogical GetComputerName(cstring,cptr culong) ;
kernel32 from "GetComputerNameA"

sigetcomputername()
store upper(id()) to mcurrentuser
msgbox(mcurrentuser + "-" + mcomputername)


FUNCTION sigetcomputername
local cname
cname = space(256)
getcomputername(cname,256)
mcomputername := trim(cname)
return


Christopher F. Neumann
[dBASE Charter Member]
Blue Star Visual dBASE graduate
ICCP TCP/IP Network Analyst
Data Communications Engineer
 
Thanks, Christopher, but I'm using dBase 5 for DOS and I don't think it has the capability to make that first call you listed. Or is there something I'm missing?
 
> dBase 5 for DOS

Ouch, sorry. I'm using dBase Plus.

Christopher F. Neumann
[dBASE Charter Member]
Blue Star Visual dBASE graduate
ICCP TCP/IP Network Analyst
Data Communications Engineer
 
Mark,

Did you received a solution for your problem. I have a simular problem with dBase IV and Novell. It occured after updating XP to SP1.
 
Sad to say, I haven't been able to discover a practical way to get the login username from a Windows 98/98se/Me DOS prompt window using the SET variables. (Windows 2000 and XP already have it.) I finally had to give up. Apparently the memory location or system variable name for the username location changed from the earlier Novell OS version. Once I changed to another server version the ID() function started returning the computer name plus "1". Interestingly, I've used Visual FoxPro and its ID() function returns both the computer name and the username in one string. So it's there, I'm sure of it, but I just can't get it populated into the SET variables without a reboot!

I was thinking I could write VBScript to grab it (my posts identify some registry keys that should work) and place it in a file that then dBase could open. But it would have added an extra layer of coding so I dropped it. Why not have the dBase user manually log in and have dBase track it?

You can read my thread329-609511 and thread615-733225 which links to thread329-731144 which links to thread329-609511 which links to thread748-733257 where I describe how I added a permanant SET variable in DOS. It doesn't help us though since to get it to propagate throughout the system environment real time you have to follow it up with a reboot. Ouch. Back to square one.

In short, you need to run Windows 2000 or XP in the Windows NT family in order to get the current ]username SET variable in the "command Prompt" window. While I admit that these OS are better than Windows 98/98se/Me it saddens me that these otherwise adequate systems are hobbled in this respect.

By the way, if you are already using Windows XP, does dBase IV have the GETENV() function? If so, then use that to get the Windows ]username SET variable. You'll just have to give up on ID() in the future.

IF LEN(GETENV("username"))>0
myID = GETENV("username")
ELSE
myID = ID() && older Windows versions
ENDIF
 
Sorry, I had a typo: ] is not part of username.

I still think it's possible to make a call outside dBase to VBScript or another Windows-aware language to grab the username (my posts identify some registry keys that hold it) and place it in a file that then dBase could open. I just did not pursue it.

dbMark
 
Oh, a warning about adding registry keys, which can be done with due caution. As I recall, the registry keys are case sensitive, so if you're not careful you could end up creating "USERNAME" and "UserName" and "username". Might apply to 98/Me or XP or both families. I think GETENV() will get only one of them.
 
For Win9x check out the following link. This is a method for setting user login/network variables into the environment.


You use putinenv to retrieve the data and set into the local environment, then use winset to set into the master windows environment, if neccesary.

I use it for controlling login scripts but, once they are set, Getenv() can also retrieve them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top