does anyone know how to find out the logged in user with domain in vc++ ?
AppDomain::CurrentDomain->SetPrincipalPolicy(PrincipalPolicy::WindowsPrincipal);
WindowsPrincipal^ user =
safe_cast<WindowsPrincipal^>(Thread::CurrentPrincipal);
Console::WriteLine(user->Identity->Name);
Well, this will return the user information according to the security
context of the current thread ... i.e. you will get the user information
under which the current thread runs. Which is most likely what you wanna
have.
Won't work if you call this from a different security context, e.g.
inside a windows service application running under one of the system
accounts ...