On Sep 5, 6:54 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
"Depechie" <glenn.versweyv...@gmail.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.com...
Hey guys,
small question. Can I find out if the current logged on use is a local
user or a domain user ?
And please don't use any solution that uses String parsing...
What I need is to get the display name of the current user and the
only way I'm able to do this is using a DLL wrapper :
[DllImport("secur32.dll", CharSet=CharSet.Auto)]
public static extern int GetUserNameEx (int nameFormat,
StringBuilder userName, ref int userNameSize);
But is there no .Net code available ??
Greets
Glenn
Get the MACHINE (System.Environment.MachineName) name and DOMAINNAME
(System.Environment.UserDomainName) from the environment, if both are equal,
you are running in a local logon session, else you are running in a domain
session with DOMAINNAME as the logon domain.
Willy.
Hey Brian and Willy,
So there is no function that actually tells me if it is a domain user
or not ?
Because I also saw the difference in DomainName and MachineName, but
that is also String checking.
But ok, if that is the only way to go, then I was on the correct
track !
Weird that .Net doesn't provide this information !! Because Windows
needs it when you start up your pc, so somehow it has to know where
the user is !
Strange....
But thanks for the nice answers