2013-04-29 20 views
24

ログインしている現在のユーザーからユーザー名を取得するWPFアプリケーションにユーザー名を表示したいですか?WPFでWindowsユーザー名を取得する方法

私の質問どのようにWPF AppからユーザーにログインしたWindowsのユーザー名を取得できますか?

答えて

40
System.Security.Principal.WindowsIdentity.GetCurrent().Name 

私も見:

Environment.UserName 

または

System.Windows.Forms.SystemInformation.UserName 

私は自分のために結果を確認するので、それを試すことができません。

を追加しました: 全ユーザー名:

Imports System.DirectoryServices.AccountManagement 

Dim userFullName As String = UserPrincipal.Current.DisplayName 
+2

System.Security.Principal.WindowsIdentity.GetCurrent()の名前、この1が動作している私だけではなく、ユーザーIDの例の完全なユーザー名を取得できますかあなたの – Ujjwal27

+1

ありがとう:代わりにUjjwal27表示「Ujjwal Vaddepati」 – Ujjwal27

+1

システムを表示します.DirectoryServices.AccountManagement.UserPrincipal.Current.UserPrincipalNameも有用であり、ADALに有意義なヒントを提供するために必要です。 –

7

コールWindowsIdentity.GetCurrent()は、WindowsのユーザーIDを取得します。

これから名前を取得できます。 。

関連する問題