Softawy 3ala tool
Posts tagged Hacks
How to get Windows Login credentials using C#.Net , ASP.Net
5one of the most famous topics is how we can know the current user credential like
user name, Groups, Authentication Type (I hope to find a way to know password
)
check this code
Console.WriteLine("AuthenticationType =" + WindowsIdentity.GetCurrent().AuthenticationType); Console.WriteLine("Name ="+WindowsIdentity.GetCurrent().Name); Console.WriteLine("Groups :"); foreach (IdentityReference ir in WindowsIdentity.GetCurrent().Groups) { Console.WriteLine(ir.Translate(typeof(NTAccount)).ToString()); }
and this a another way to get Windows Identity
WindowsPrincipal p = Thread.CurrentPrincipal as WindowsPrincipal; (p.Identity as WindowsIdentity)
and for ASP.Net
HttpContext.Current.User.Identity
for more information
Windows Principal , Windows Identity