Results 1 to 4 of 4

Thread: Very Urgent - Get User ID

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    229

    Very Urgent - Get User ID



    Hi ...

    Does anyone know how to get User ID
    from NT/Novell using API ?
    Pls let me know.

    Thank you
    Keiko

  2. #2
    Guest

    Lightbulb

    This is what I did


    Private Sub GetLoginName()
    Dim lRetVal as Long 'result of the API functions
    Dim hKey as Long 'Handle of opened key
    Dim vValue As Variant 'Setting of queried value
    Dim vValue2 As Variant 'Setting of queried value

    lRetVal = RegOpenKeyEx(HKEY_Local_Machine, "network\logon", 0, KEY_ALL_ACCESS, hKey)

    lRetVal = QueryValEx(hKey, "username", vValue)

    LoginName = vValue 'vValue is whatever is at the registry setting

    lRetVal2 = RegOpenKeyEx(HKEY_Local_Machine, "network\uid", 0, KEY_ALL_ACCESS, hKey)

    lRetVal2 = QueryValEx(hKey, "userid", vValue)

    Userid = vValue2 'vValue is whatever is at the registry setting

    RegCloseKey(hKey)

    Private Sub cmdExit_Click()
    End
    End Sub

    Private Sub Form_Load()
    Dim lRetValue as Long 'result of the api functions
    Dim hKey as Long ' handle of the opened key
    Dim vValue as vatiant 'Setting of queried value

    lRetVal = RegOpenKeyEx(HKEY_Local_Machine, "network\logon", 0, KEY_ALL_ACCESS, hKey)

    lRetVal = QueryValEx(hKey, "username", vValue)

    LoginName = vValue 'vValue is whatever is at the registry setting

    lRetVal2 = RegOpenKeyEx(HKEY_Local_Machine, "network\uid", 0, KEY_ALL_ACCESS, hKey)

    lRetVal2 = QueryValEx(hKey, "userid", vValue)

    Userid = vValue2 'vValue is whatever is at the registry setting

    RegCloseKey(hKey)

    Label1.caption = "Your UserName is; " & loginName & "" _
    + Char$(13) + "Welcome " & LoginName & "" _
    + Char$(13) + "Date " & Date & "" _
    + Char$(13) + "Time " & Time & ""

    MsgBox "" & F_GetUSerName & ""

    Private Function F_GetUserName() as String
    Dim strUser as String

    strUser = Space(150)

    If GetUserName(strUser, 150) = o then
    F_GetUserName = ""
    Exit Function
    End if

    'Take out the null value
    strUser = mid(Trim(strUser), 1, Len(Trim(strUser))-1)

    F_GetUserName = strUser

    End Function

    hope this works for you. Good Luck

    John

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    229

    Thanks

  4. #4
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217

    Thumbs down

    Oh my god! You don't need to do all that. Just use the GetUserName API!
    Code:
    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    [Edited by SonGouki on 04-27-2000 at 03:45 PM]

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