Get NTlogin from Generic User
Using VB as front end.
Using Generic User (DBuser)who has all appropriate rights to all procedures
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?
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)
GetName = ""
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.
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