Here is some code I found to get the nt user name using VB. However, I have not been able to successfully transfer the functions to ASP. <br><br><br>Private Const UNKNOWN = _<br>"(Value Unknown Because System Call Failed)"<br><br>Private Declare Function GetUserName Lib "advapi32.dll" _<br>Alias "GetUserNameA" (ByVal lpBuffer As String, nSize _<br>As Long) As Long<br><br>Public Function GetCurrentUserName() As String<br><br>Dim l As Long<br>Dim sUser As String<br><br>sUser = Space$(255)<br>l = GetUserName(sUser, 255)<br><br>'strip null terminator<br><br>If l <> 0 Then<br> GetCurrentUserName = Left(sUser, InStr(sUser, Chr(0)) - 1)<br><br><br>Else<br> Err.Raise Err.LastDllError, , _<br> "A system call returned an error code of " _<br> & Err.LastDllError<br>End If<br><br>End Function
Here, I just wrote this routine which will return the NT username. Of course to get NT user name, you must have authentication set up on the webserver... don't try to do it with anonymous access allowed (duh).<br><br>Function NTUserName()<br> 'declare variables<br> Dim logon, myArray<br><br> 'will return Domain\Username or just Username depending<br> 'if the user is logged into the domain or their local machine. also browser dependent. go figure.<br> logon = Request.ServerVariables("LOGON_USER"<br><br> 'so we split the logon variable by the "\"<br> myArray = Split(logon, "\", -1, 1)<br><br> 'take the upper bound of the logon variable<br> logon = myArray(Ubound(myarray))<br><br> 'and you're left with just the NT Username<br> NTUserName = logon<br><br>End Function<br><br>Happy programming
JF,<br>Thanks for your clafification. I should look more onto what is available under server variables. My Access friends were telling me about Windows api calls to get the NT Userid. You should put this under FAQ for ASP and VI.<br>HL
Yes it will work with PWS. Set the authentication for NT Challenge Response (IE) and Basic Authentication (for Netscape). How do you set authentication...<br>From the Management console, choose directory security... the tabs and dialogs are pretty intuitive from there. <p> <br><a href=mailto: > </a><br><a href=
hi there,
I am newbie.Finaly I found how to return nt user code.I am using DMX where do i have to paste your code and how to display on the page to test and then make not visible
thank you
Nat
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.