user info

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as
System.Security.Principal.WindowsPrincipal;

p.Identity.Name tells me userId. how do I get out not only the log in name
but also the name of the person who is inlogged in the system???
 
To best my knowledge would only return an initialized
WindowsPrinicipal if somewhere program had assigned this previously,
otherwise this would just be a blank GenericPrincipal.

If the quoted line of code is working, it appears to me that some
piece of code had previously 'constructed' an object of
WindowsPrincipal by itself and then assigned it as thread's principal.

To get WindowsPrinicipal of current OS logged-in user you may do
following

WindowsPrincipal p = new
WindowsPrincipal(WindowsIdentity.GetCurrent());
 
To best my knowledge Thread.CurrentPrincipal would only return an
initialized WindowsPrinicipal if somewhere program had assigned this
previously, otherwise this would just be a blank GenericPrincipal.

If the quoted line of code is working, it appears to me that some
piece of code had previously 'constructed' an object of
WindowsPrincipal by itself and then assigned it as thread's
principal.


To get WindowsPrinicipal of current OS logged-in user you may do
following


WindowsPrincipal p = new
WindowsPrincipal(WindowsIdentity.GetCurrent());
 
Hi,

Sorry but I still don't get it. How would I be able to get out full name
(user full name) out of the windowsPrincipal p object???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top