Results 1 to 5 of 5

Thread: User Connected

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    188
    I need to know the name of the user or the group that the current connection is connected with. I am using NT security and a SQL Server database for the connection. Is there anyway to get this information?

    If this isn't clear let me know and I'll try to explain better...

  2. #2
    Guest
    i hope you mean the logon Name from Windows NT

    Declare Function WNetGetUser Lib "mpr" Alias "WNetGetUserA" (ByVal lpName As String, ByVal LpUserName As String, LpnLength As Long) As Long

    Function Get_NT_UserName() As String

    Dim RetVal As Long, NamePuffer As String,Namen As String

    NamePuffer = Space(255)
    RetVal = WNetGetUser(vbNullString, NamePuffer, Len(NamePuffer))
    Namen= Trim(NamePuffer)

    If InStr(1, namen, Chr$(0)) > 0 Then
    Namen = Left(Namen, Len(Namen)- 1)
    Else
    Namen = ""
    End If

    Get_NT_UserName = Namen

    End Function

  3. #3
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196
    check out the sysprocesses table from the master database.

  4. #4
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196
    To be more specific, here's a SQL example

    * You should have access to the master database.

    USE MASTER
    select hostname, program_name, nt_domain, nt_username, loginame from sysprocesses where dbid = db_id('northwind')

    select spid, hostname, program_name, nt_domain, nt_username, loginame from sysprocesses where spid = user_id(current_user)

    Hope this helps

    [Edited by RIVES on 09-19-2000 at 02:19 PM]

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    188
    thanx both of you...

    Rives,
    I don't have access to the sysprocesses table

    maexchen,
    I know how to get the name they used to log onto the machine, do you know how to get the names of any groups that they belong to?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width