Getting Network Logon Id (OpenInsight Specific)
At 09 MAY 2000 09:39:45AM Simon Wilmot wrote:
Can anyone point me at the best way to programmatically get the Network logon Id from the OS, either via an internal function or from a DLL call for standard DLL's.
This is to work for Win95/98/NT and for NT/Novell networks.
If using a DLL, can you add the necessary declaration details,
Simon
At 09 MAY 2000 11:30AM Colin Rule wrote:
As per the OI HLP, the @STATION variable contains this.
@STATION
The network station identifier (or null for non-networked versions).
At 10 MAY 2000 03:47AM Simon Wilmot wrote:
Unfortunately the @Station variable contains the identifier for the PC which is not necessarily the Network Logon Id.
For example my PC name is 'Simon Wilmot', which @Station contains but I log on to the network using the logon Id 'SWilmot'.
At 10 MAY 2000 04:18AM Steve Smith wrote:
Novell networks offer the feature of setting the login ID in the environment from the server logon script.
Microsoft NT places the user name in an environment variable by default.
So you can pick this up from the environment. See Revelation's posting here
At 11 MAY 2000 03:52AM Simon Wilmot wrote:
This almost worked - unless I am missing an update from somewhere,
LPSTR is not supported. LPCHAR works, but as it returns up to a null terminating character, will only return the first environment variable.
Any other ideas / how do I get LPSTR supported ??
Simon
At 11 MAY 2000 08:41AM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:
Simon,
LPSTR is basically LPCHAR - a long pointer to a string terminated by (char) zero. However, when you use LPCHAR to get data from outside of OpenEngine, it takes the step of trying to convert it to a Basic+ string for you.
However, as the data you are trying to retrieve is char(0)-delimited you'll only get the first item back, as OpenEngine stops when it gets to the first char(0).
What you need to do is get back the actual pointer and de-reference it yourself. You can do this by
1) Changing the returned pointer definition from getDOSEnvironment() from LPCHAR to LPVOID - Now OE won't do the conversion.
LPVOID PASCAL GetDOSEnvironment( VOID )
2) Dereferencing the pointer using getValue() and walking along the memory block yourself until you get to 2 null chars.
eg..
declare function GetDOSEnvironment envStr = "" envLen = 2 lpEnv = GetDOSEnvironment() eof = 0 loop envStr=getValue( lpEnv , Char, envLen ) if envStr-2,2=\0000\ then eof=1 envStr-2,2=" end else envLen += 1 end until eof repeat convert \00\ to @Fm in envStrThe reason we have to walk along the string is that we don't know the length of it in advance - if we go to far we get a GPF, so we have to test each step…
Captain C USS Sprezzatura NCC-1701X
Galactic Leaders in All Thangs RevSoft
At 16 MAY 2000 05:35AM Simon Wilmot wrote:
Thanks for that, details returned fine ….
Unfortunately, in scenario of Windows 95 workstation on NT network, the Network logon Id is not held in any of the variables returned.
Any other ideas ??
Simon
At 17 MAY 2000 04:30AM Steve Smith wrote:
Simon - email me on steve@state-of-the-art.com.au
I have a utility which will set the computer name / username in the environment for you -it used to work under Lan Manager - you'll have to test it on Win 95.
Steve
At 19 MAY 2000 03:58AM Simon Wilmot wrote:
Unfortunately no go with this possible solution.
I know if the logon script were amended to set a Username Dos variable then the previous GetDosEnvironment would work, but if possible I would like a Generic solution.
Simon
At 19 MAY 2000 08:19AM Steve Smith wrote:
Differing networks and differing OS versions dictate different network APIs and different locking and different get-username functions with application which inherit this diversity at the
network OS level.
Steve
At 19 MAY 2000 11:47AM Warren wrote:
On NT stations create a batch file that does the following:
echo %username% ] c:\uname.txt
Then read uname.txt as part of your login process in ARev and set it to a labeled common variable.