Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1389
  • Last Modified:

ASP GETUSERNAME API

How can i use the api getUserName cuz i dont know how, please explain me detail to detail. Where is the option explicit locate?
Where do i write your script jamestthomas?
explain me step by step like the song.
Thanks folk, it is true thanks
<%Option Explicit

Private Declare Function GetUserName& Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long)
                                   
Function ReturnUser$()
Dim s$, cnt&, dl&
cnt& = 199
s$ = String$(200, 0)
On Err GoTo ErrorHandle
dl& = GetUserName(s$, cnt)
ReturnUser$ = Left$(s$, cnt)
Exit Function
ErrorHandle:
ReturnUser$ = "error: " & Err.Description
Exit Function
End Function

%>
0
Fabioxp
Asked:
Fabioxp
1 Solution
 
hamidovtCommented:
it is and ASP code... However yo can use it in VB as well.

Private Declare Function GetUserName& Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long)
is the definition of the function GetUserName, which is stored in advapi32.dll

As for the function, I dont think it is right... Check this one

Function sGetUser() As String                            
' Returns current network logon
' Usage:      ="Network User Name: " & sGetUser()

    Dim s$, cnt&, dl&, sWho As String

    cnt& = 199
    s$ = String$(200, 0)
    dl& = GetUserName(s$, cnt)
    sGetUser = Left$(s$, cnt - 1)

End Function

I found it on http://p2p.wrox.com/archive/access/2001-12/63.asp

If you have VB installed, just copy paste this code and use it as described in the comment.
Something like

Mgsbox "Network User Name: " & sGetUser()

0
 
AzraSoundCommented:
You cannot use API calls directly from an ASP page.   You must wrap it up in a COM DLL that you can then access from ASP.
0
 
CaptainRantflapsCommented:
if all you are after is the username i find the

username = Request.ServerVariables("logon_user")

works fine for me.

0
 
AzraSoundCommented:
Recommendation: No refund, save as 0-pt PAQ
0
 
moduloCommented:
PAQed - no points refunded (of 50)

modulo
Community Support Moderator
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now