By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,027 Members | 1,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,027 IT Pros & Developers. It's quick & easy.

Unable to capture NT login in to a data access page

P: 3

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.
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
  2.     "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  4. Function fOSUserName() As String
  5. ' Returns the network login name
  6. Dim lngLen As Long, lngX As Long
  7. Dim strUserName As String
  8.     strUserName = String$(254, 0)
  9.     lngLen = 255
  10.     lngX = apiGetUserName(strUserName, lngLen)
  11.     If (lngX > 0) Then
  12.         fOSUserName = Left$(strUserName, lngLen - 1)
  13.     Else
  14.         fOSUserName = vbNullString
  15.     End If
  16. 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...
Sep 29 '08 #1
Share this Question
Share on Google+
4 Replies

P: 50
You may be over complicating what needs to be done.

I use :
Expand|Select|Wrap|Line Numbers
  1. Dim s_User
  2.     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.
Sep 29 '08 #2

Expert Mod 15k+
P: 31,615
I use :
Expand|Select|Wrap|Line Numbers
  1. 'GetUser returns the user's logged on name.
  2. Public Function GetUser() As String
  3.     Dim strUserKey As String
  5.     If Environ("OS") = "Windows_NT" Then
  6.         strUserKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
  7.         GetUser = RegRead(conHKLM, strUserKey, "DefaultUserName")
  8.     Else
  9.         'Windows
  10.         strUserKey = "Network\Logon"
  11.         GetUser = RegRead(conHKLM, strUserKey, "username")
  12.     End If
  13. End Function
I don't know how well this will work in an ASP. I never use them myself.
Sep 29 '08 #3

P: 3

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...
Oct 1 '08 #4

Expert Mod 15k+
P: 31,615
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.
Oct 2 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.