Hi All
I did post this in VB General but no-one can come up with a answer there so...
How can I get the local users full logon name under VB.Net now i.e. John Smith as opposed to SmithJ
There was a function for VB6 that would return this but under NET...

Get Local Users Full Name
JT_AnnArbor
Very cool. I'm following up with that team to see if this might make a good snippet or addition to "My" at some point in the future. Thanks, Paul!
Chule
Not a bad idea Matthew. Given the complexity of System.DirectoryServices and the LDAP provider you might want to consider exposing some of that information through "My" as well.
NealRM
This was essentially what I used under VB6. Unfortunately it doesn't port to VB.Net.
Strauslin
CB Thirumalai
Well, I remember doing something similar at school with Visual Basic 6. Basically, it queries the domain controller, and gets the user's full name (eg. Daniel Lo Nigro) if you pass it the username (eg. lon01, which is my username at school)
The code I used can be found at http://vbnet.mvps.org/code/network/netusergetinfo.htm (at least, I think that's the code, I do know I got it from VBNet). If you logon to a domain controller, then you need to type the server's name in to the box.
Rod DeValcourt
Nope, it doesn't, that's why I'm looking for a .NET OK way to do it.
Robert Kitson
mobiledev1
If you're looking for the full name there are a couple different methods you can use. The below code uses System.DirectoryServices:
Dim DomainUser As String = System.Security.Principal.WindowsIdentity.GetCurrent.Name.Replace("\", "/")
Dim ADEntry As New System.DirectoryServices.DirectoryEntry("WinNT://" & DomainUser)
Dim FullName As String = ADEntry.Properties("FullName").Value
vkv
The only mechanisms I'm aware of which can return the user's name will do so with the DOMAIN\USERNAME format (which is really all the machine knows about you) if using Windows auth, or just the USERNAME otherwise. Code for that would look like this (I shamelessly stole this from MSDN):
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