Unable to capture NT login in to a data access page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mirajsen
    New Member
    • Sep 2008
    • 3

    Unable to capture NT login in to a data access page

    Hello,

    I have a data access page which is linked with a table. Users will enter the data through this particular DAP which is on a web server. I would like the DAP to capture and append the NT login ID of these users who are entering the data into the table.

    I used the following code to capture the NTlogin.
    Code:
    Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
        "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    
    Function fOSUserName() As String
    ' Returns the network login name
    Dim lngLen As Long, lngX As Long
    Dim strUserName As String
        strUserName = String$(254, 0)
        lngLen = 255
        lngX = apiGetUserName(strUserName, lngLen)
        If (lngX > 0) Then
            fOSUserName = Left$(strUserName, lngLen - 1)
        Else
            fOSUserName = vbNullString
        End If
    End Function
    When I call this function from a form through a text box, it displays the NT login ID as the default value.

    But, when I try to use the same method in a DAP, it is not accepting =fOSUsername() as a default value.

    Any ideas?

    PS: A begginer...
    Last edited by NeoPa; Sep 29 '08, 05:13 PM. Reason: Please remember to use the [CODE] tags provided
  • Krandor
    New Member
    • Aug 2008
    • 50

    #2
    You may be over complicating what needs to be done.

    I use :
    Code:
    Dim s_User
        s_User = Request.ServerVariables("AUTH_USER")
    It always delivers the correct id. This assumes that the user is logged into the network before going to the web page.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      I use :
      Code:
      'GetUser returns the user's logged on name.
      Public Function GetUser() As String
          Dim strUserKey As String
      
          If Environ("OS") = "Windows_NT" Then
              strUserKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
              GetUser = RegRead(conHKLM, strUserKey, "DefaultUserName")
          Else
              'Windows
              strUserKey = "Network\Logon"
              GetUser = RegRead(conHKLM, strUserKey, "username")
          End If
      End Function
      I don't know how well this will work in an ASP. I never use them myself.

      Comment

      • mirajsen
        New Member
        • Sep 2008
        • 3

        #4
        Hello,

        Sorry to inform you that my concern is different.

        The issue is, I would like to have the NT login ID to be displayed as the default value of the text box which is linked to the table. It is working on a form. But not on a Data Access Page. Again the requirement is to capture the NT Login along with the data, which the users are gonna input.

        Any thoughts?

        PS: A beginner...

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32656

          #5
          I've not given up on you. I've just been short of time recently. Will get back to this again when I can.

          Bump the thread if you've not heard from me again before the weekend.

          Comment

          Working...