DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Rafael Rangel Guest

    NetWorking VFP 6


    I am working in VFP 6.0. Is there a way to know the User Name, or Station,
    connected to the network?. I need, from my program, get the user that logon
    or logoff the network, to log that in a dbf file.
    I am in a Windows NT environment. Thanks

  2. #2
    John C. Gunvaldson Guest

    Re: NetWorking VFP 6

    Lots of things,

    One of the easiest is to use the following in a Custom Method:

    *// Local Variables
    LOCAL lcReturn, lcNTUser, lc98User, lcOsVer

    *// Default Assignments
    lcReturn = DODEFAULT()
    lcOsVer = OS()
    lcNTUser = ""
    lc98User = ""

    *// ID User's Operating System - and Determine Login Name
    DO CASE

    CASE "NT" $ ALLTRIM(UPPER(lcOsVer))
    lcUser = IIF(NOT EMPTY(GETENV('USERNAME')), ;
    GETENV('USERNAME'),GETENV('USER'))

    CASE "98" $ ALLTRIM(UPPER(lcOsVer))
    lcUser = IIF(NOT EMPTY(GETENV('USER')), ;
    GETENV('USER'),GETENV('S_FILE'))

    CASE "95" $ ALLTRIM(UPPER(lcOsVer))
    lcUser = IIF(NOT EMPTY(GETENV('USER')), ;
    GETENV('USER'),GETENV('S_FILE'))

    OTHERWISE && Try to retrieve NetWare Info
    lcUser = IIF(NOT EMPTY(GETENV('USER')), ;
    GETENV('USER'),GETENV('LOGIN_NAME'))

    ENDCASE

    *// Store - and modify Case - if Needed
    IF NOT EMPTY(lcUser)
    THIS.VALUE = ALLTRIM(lcUser)
    ENDIF

    *// Back
    RETURN (lcReturn)


    hth


    John C. Gunvaldson
    CNE, MCP(x5)
    San Diego, CA


    "Rafael Rangel" <rrangel@data-lock.com> wrote in message
    news:38d7d873$1@news.devx.com...
    >
    > I am working in VFP 6.0. Is there a way to know the User Name, or Station,
    > connected to the network?. I need, from my program, get the user that

    logon
    > or logoff the network, to log that in a dbf file.
    > I am in a Windows NT environment. Thanks




  3. #3
    Garrett Fitzgerald Guest

    Re: NetWorking VFP 6

    In article <38d7ed20$1@news.devx.com>, foxnet_west@hotmail.com (John
    C. Gunvaldson) quoth...
    > CASE "NT" $ ALLTRIM(UPPER(lcOsVer))
    > lcUser = IIF(NOT EMPTY(GETENV('USERNAME')), ;
    > GETENV('USERNAME'),GETENV('USER'))


    http://support.microsoft.com/support.../q250/5/12.asp
    --
    Garrett Fitzgerald
    #INCLUDE "\Program Files\Microsoft Visual Studio\VFP98\stddsclm.h"
    (Anyone who thinks I do anything vaguely resembling speaking for Microsoft
    is sorely deluded...)

  4. #4
    John C. Gunvaldson Guest

    Re: NetWorking VFP 6

    Hmmm,

    Based upon Garrett finding the Windows 2000 info kb, one might
    want to create new version of Login Name environment catcher
    as follows?

    *//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    *// Local Variables
    LOCAL lnSelect, lcReturn, lcUser

    *// Default Assignments
    lnSelect = Select()
    llReturn = DoDefault()
    lcUser = ""

    *// ID User's OS - Obtain Env. Variable For User
    Do Case

    *// Tests for Windows 2000 or NT 4.0
    Case "5.00" $ OS() OR "NT 4.00" $ OS()

    lcUser = IIF(NOT EMPTY(GETENV('USERNAME')), ;
    GETENV('USERNAME'),GETENV('USER'))

    *// Tests for Windows 98 or 95
    Case "4.00" $ OS() OR "4.10" $ OS()

    lcUser = IIF(NOT EMPTY(GETENV('USER')), ;
    GETENV('USER'),GETENV('S_FILE'))

    *// Try to retrieve NetWare Info?
    OtherWise

    lcUser = IIF(NOT EMPTY(GETENV('USER')), ;
    GETENV('USER'),GETENV('LOGIN_NAME'))
    EndCase

    *// Could be used in a Users Login Name txtBox?
    If Not Empty(lcUser)
    This.value = AllTrim(lcUser)
    ENDIF

    *// Or - Return Value if Used as Custom Method?
    Return Iff( llReturn, AllTrim(lcUser),"")

    *//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Good Catch Garrett, as I use this in a legacy App, I am going back and make
    updates based upon kb...

    Thanks

    John C. Gunvaldson
    San Diego, CA





  5. #5
    John C. Gunvaldson Guest

    Re: NetWorking VFP 6

    Ok,

    ^
    I saw it <g> To correct Above |

    1 - Have llReturn assigned a logical based upon something - dunno, maybe
    empty values or something?

    2 - Change Iff - to - IIF

    Too fast with fingers <sigh>.... Otherwise, just checked it with Windows
    2000 here - works fine.

    John




  6. #6
    Garrett Fitzgerald Guest

    Re: NetWorking VFP 6

    "John C. Gunvaldson" <foxnet_west@hotmail.com> wrote in message
    news:38d94a0b@news.devx.com...
    > Hmmm,
    >
    > Based upon Garrett finding the Windows 2000 info kb, one might
    > want to create new version of Login Name environment catcher
    > as follows?


    Ah. I'm at home now, so I can talk. :-) As my article pointed out, the
    GetVersionInfoEx() function is a better way to test 9x/NT differences. I
    wrote a wonderful little class encapsulating the functionality, but TPTB
    decided it duplicated Q188897 too closely. Would someone like to write it
    themselves and post it here or on the Universal Thread? :-) Most of the code
    is in that article -- you just need to add a little to cover everything that
    function does.....



  7. #7
    Ed Rauh Guest

    Re: NetWorking VFP 6

    SYS(0) returns the current Windows userid and NetBIOS station ID. There are
    also API calls that cna be made to determine the user id other than the base
    WIndows ID for a particular server using WNetGetUser() given the name of an
    accessible share on the server or a local resource mapped to a specific
    share.

    "Rafael Rangel" <rrangel@data-lock.com> wrote in message
    news:38d7d873$1@news.devx.com...
    >
    > I am working in VFP 6.0. Is there a way to know the User Name, or Station,
    > connected to the network?. I need, from my program, get the user that

    logon
    > or logoff the network, to log that in a dbf file.
    > I am in a Windows NT environment. Thanks




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links