Solved

ASP GETUSERNAME API

Posted on 2003-10-21
7
1,348 Views
Last Modified: 2008-02-01
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
Comment
Question by:Fabioxp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 4

Expert Comment

by:hamidovt
ID: 9597078
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
 
LVL 28

Expert Comment

by:AzraSound
ID: 9599461
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
 
LVL 5

Expert Comment

by:CaptainRantflaps
ID: 9971945
if all you are after is the username i find the

username = Request.ServerVariables("logon_user")

works fine for me.

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 11369602
Recommendation: No refund, save as 0-pt PAQ
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11667889
PAQed - no points refunded (of 50)

modulo
Community Support Moderator
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question