Results 1 to 19 of 19

Thread: [02/03] Determining XP Login Credentials within VB

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    115

    [02/03] Determining XP Login Credentials within VB

    Is there a simple way to determine if the user running a vb program logged in to windows with administrator rights?

    The stuff I found on msdn seems very complex.

    Update:

    All I really care about is the user name. It does not have to be high security.
    I found this function however I dont think it works in 2002. Anyone know an equivalent?

    Code:
    Function GetUserName() As String
            If TypeOf My.User.CurrentPrincipal Is _
            Security.Principal.WindowsPrincipal Then
                ' The application is using Windows authentication.
                ' The name format is DOMAIN\USERNAME.
                Dim parts() As String = Split(My.User.Name, "\")
                Dim username As String = parts(1)
                Return username
            Else
                ' The application is using custom authentication.
                Return My.User.Name
            End If
        End Function
    Last edited by jeffnyc; Jul 11th, 2007 at 10:32 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