Trying to use Lin ADVAPI32.DLL in ASP.

Discussion in 'ASP General' started by Alex Wolff, Sep 21, 2004.

  1. Alex Wolff

    Alex Wolff Guest

    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.
    Alex Wolff, Sep 21, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    1,375
    Joe Kaplan \(MVP - ADSI\)
    Sep 28, 2005
  2. Blacksheep
    Replies:
    1
    Views:
    2,201
    White Wolf
    Aug 28, 2003
  3. Podi
    Replies:
    2
    Views:
    807
  4. Replies:
    7
    Views:
    253
  5. C

    advapi32.dll / LogonUser

    C, May 16, 2006, in forum: ASP .Net Security
    Replies:
    3
    Views:
    853
    Henning Krause [MVP]
    May 17, 2006
Loading...

Share This Page