473,396 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Windows user name

With

System.Security.Principal.WindowsIdentity.GetCurre nt().Name

I get the user name of the current Windows user.
But how can I get the full name?

Thanks
Ferdinand
Jan 26 '06 #1
4 12910
Ferdinand,

In order to do this, you would have to call the GetUserNameEx API
function through P/Invoke, passing the value of NameDisplay for the
NameFormat parameter.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ferdinand Zaubzer" <fe***@gmx.at> wrote in message
news:O3*************@tk2msftngp13.phx.gbl...
With

System.Security.Principal.WindowsIdentity.GetCurre nt().Name

I get the user name of the current Windows user.
But how can I get the full name?

Thanks
Ferdinand

Jan 26 '06 #2

"Ferdinand Zaubzer" <fe***@gmx.at> wrote in message
news:O3*************@tk2msftngp13.phx.gbl...
| With
|
| System.Security.Principal.WindowsIdentity.GetCurre nt().Name
|
| I get the user name of the current Windows user.
| But how can I get the full name?
|
| Thanks
| Ferdinand

Using the System.DirectoryServices namespace classes:

....
// get fullname of 'username' on 'servername'
using (DirectoryEntry domain = new
DirectoryEntry("WinNT://servername/username"))
{
string fullName = domain.Properties["FullName"].Value;
}

Willy.
Jan 26 '06 #3
Willy Denoyette [MVP] wrote:
"Ferdinand Zaubzer" <fe***@gmx.at> wrote in message
news:O3*************@tk2msftngp13.phx.gbl...
| With
|
| System.Security.Principal.WindowsIdentity.GetCurre nt().Name
|
| I get the user name of the current Windows user.
| But how can I get the full name?
|
| Thanks
| Ferdinand

Using the System.DirectoryServices namespace classes:

...
// get fullname of 'username' on 'servername'
using (DirectoryEntry domain = new
DirectoryEntry("WinNT://servername/username"))
{
string fullName = domain.Properties["FullName"].Value;
}


Thanks for the Hint!
But I don't have this System.DirectoryServices namespace.
Do I have to install any extensions?

Thanks
Ferdinand
Jan 27 '06 #4
No, you have to set a reference to the System.DirectoryServices assembly.

Willy.

"Ferdinand Zaubzer" <fe***@gmx.at> wrote in message
news:43**************@gmx.at...
| Willy Denoyette [MVP] wrote:
| > "Ferdinand Zaubzer" <fe***@gmx.at> wrote in message
| > news:O3*************@tk2msftngp13.phx.gbl...
| > | With
| > |
| > | System.Security.Principal.WindowsIdentity.GetCurre nt().Name
| > |
| > | I get the user name of the current Windows user.
| > | But how can I get the full name?
| > |
| > | Thanks
| > | Ferdinand
| >
| > Using the System.DirectoryServices namespace classes:
| >
| > ...
| > // get fullname of 'username' on 'servername'
| > using (DirectoryEntry domain = new
| > DirectoryEntry("WinNT://servername/username"))
| > {
| > string fullName = domain.Properties["FullName"].Value;
| > }
|
| Thanks for the Hint!
| But I don't have this System.DirectoryServices namespace.
| Do I have to install any extensions?
|
| Thanks
| Ferdinand
Jan 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bob Everland | last post by:
I have an application that is ISAPI and the only way to secure it is through NT permissions. I need to have a way to login to windows authentication so that when I get to the ISAPI application no...
2
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
3
by: Steven Fox | last post by:
============================================================ About DB2 Administration Tools Environment ============================================================ DB2 administration tools level:...
5
by: pberna | last post by:
Dear all, I built a Web Form application to start and stop a Windows Service remotely. I successful tested the application on Windows 2000 server + IIS. I must include the ASPNET user to the...
3
by: Amjad | last post by:
Hi, I just wrote a test Windows Service that creates a text file on startup (please see my code below). The file is never created. Protected Overrides Sub OnStart(ByVal args() As String) Dim...
3
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work...
9
by: Alex | last post by:
Get the Name and Phone Number of the Current Windows User in a .NET Application I am writing a simple .NET (C#) application. It needs to "automatic" get the Name (last, first) and phone number...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
4
by: =?Utf-8?B?QXZhRGV2?= | last post by:
ASP.Net 2. We are migrating to Windows 2008 64 bit Server with IIS 7 from Windows 2003 32 Bit with IIS 6. A few library classes we wrote uses impersonation in code like explained in this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.