DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Matthew Mark Guest

    Get NTlogin from Generic User


    Using VB as front end.
    Using Generic User (DBuser)who has all appropriate rights to all procedures
    in database.

    Problem is when using suser_sname(), either as default or in an update proc,
    it supplies the login user into SQL Server, not the NT login name. I need
    to trap the NT Login name. Does anyone know how to do this?



  2. #2
    Colin Guest

    Re: Get NTlogin from Generic User


    Heres how to do it in VB

    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
    (ByVal lpBuffer As String, nSize As Long) As Long


    Public Function GetName() As String

    Dim lSize As Long
    Dim sBuffer As String
    sBuffer = Space(255)
    lSize = Len(sBuffer)
    Call GetUserName(sBuffer, lSize)
    If lSize > 0 Then
    GetName = Left$(sBuffer, lSize)
    Else
    GetName = ""
    End If
    End Function


    You could then pass this value as an argument to your stored procedure. I
    am unsure if you can get the NTLogin for a generic user name.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links