Solved

what is the code in VB to get current user logon in windows?

Posted on 2008-10-07
1
491 Views
Last Modified: 2013-11-25
what is the code in VB to get current user logon in windows?
here is the code I am using
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
        parts() = Split(My.User.name, "\")

        Dim username As String
        username = parts(1)

        Return username

    Else

        ' The application is using custom authentication.

        Return My.User.Name

    End If

End Function

'Dim name As String
    'name = My.User.name
    'MsgBox (name)
0
Comment
Question by:Harter
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 22661977
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question