Microsoft KB Archive/99921

= How To Obtain Network User IDs from Within FoxPro =

Article ID: 99921

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.0
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.5a

-



This article was previously published under Q99921



SUMMARY
To create unique filenames based on individual workstation operators, each user's identification (ID) must be obtained from the environment. Third-party API libraries that can interface with the network to provide this information are available; however, you can also use a batch file to capture the user IDs during interactive logins if only medium security is required.



MORE INFORMATION
To capture a user ID, you must create a batch file with the same name as the command normally executed to log in. For example, if the normal method is to type LOGIN followed by an ID, the batch file would be named LOGIN.BAT.

To create the file:

 In a text editor, create a new file with the appropriate name. Within the new file, type the following:

SET USER=%1 CD NET LOGIN %1

 Save the file in the root directory.

The next time the machine completes startup, LOGIN and the user ID are typed in as normal, but at subsequent logins, the LOGIN.BAT file will intercept the user ID and assign the ID (passed as the first parameter on the command line, [%1]) to the MS-DOS environment variable USER and then pass it to the original LOGIN program in the NET subdirectory.

If the network LOGIN file is found through the MS-DOS PATH statement, place LOGIN.BAT in the root directory so that it will be executed first. However, if the AUTOEXEC.BAT selects the subdirectory where the original LOGIN program is found, you need to modify AUTOEXEC.BAT to find LOGIN.BAT first. For added security, you can mark the LOGIN.BAT file as Hidden with the MS-DOS ATTRIB command.

Once the login is finished and FoxPro is running, the ID can be retrieved with the GETENV function. The following commands demonstrate its usage: usrname=GETENV(&quot;USER&quot;) The variable usrname contains the user ID.

Additional query words: password logon

Keywords: kbhowto kbinterop kbnetwork kb3rdparty KB99921

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.