Trying to use Lin ADVAPI32.DLL in ASP.

A

Alex Wolff

Hello,

I have the following snippet of code, which in VB gives me the current
network login. I am trying to migrate the code to asp so I can use it from a
web page. When I call my asp page the web server returns an error:
Technical Information (for support personnel)

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/SLApprover/MyVersion.asp, line 3, column 8


***Code Snippet Begins Here****
<%@ Language=VBScript %>
<%
Declare function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal
lpBuffer As String, nSize As Long) As Long

Dim NTUserName

function OSUserName()
Dim cn as String
Dim ls as Long
Dim res as Long
cn = String(1024, 0)
ls = 1024
res = GetUserName(cn, ls)
If res <> 0 Then
OSusername = mid(cn, 1, InStr(cn, Chr(0)) - 1)
Else
OSusername = ""
End if
end function

NTUserName = OSUserName()
Response.Write("The NT User Name is: " & NTUserName)

%>
***Code Snippet End Here****



Any obvious problems? Can I not call the windows API libraries from ASP?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top