Hi all...
My question is -
What is the difference between -
1. Page.User.Identity.Name
2. HttpContext.Current.User.Identity.Name.ToString();
3. System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
4.System.Environment.UserName;
-----------
Which is the best method to get the current logged in username for all Single Sign On Applications ??
------------
Which statement is to be used in which scenario ??
-------
Please explain.
Loading
Riddhi ValechaPosted Feb 4, 2015, 7:22 AM
I want to know the technical difference between the 4 statements -
1. Page.User.Identity.Name
2. HttpContext.Current.User.Identity.Name.ToString();
3. System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
4.System.Environment.UserName;
--
Also... in which situations to use which statements......
PLease give some links or explanation... if possible...
PLease Help !
Burak SeyhanPosted Feb 4, 2015, 4:57 AM
Riddhi ValechaPosted Feb 4, 2015, 4:53 AM
I have tried all the things...none is working on live server...
All are fine on local system...
Please guide...
Burak SeyhanPosted Feb 4, 2015, 4:46 AM
Riddhi ValechaPosted Feb 4, 2015, 4:43 AM
I loaded my website using
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
But, it is not working.
My Logic -
String username =
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
---
If(username.Lenght > 0) // USername is not null
{
//Check in database if user exists or not.
//If yes, redirect to home page.
//Else, redirect to error page.
}
----------
Everytime, it is redirecting me to error page.
Burak SeyhanPosted Feb 4, 2015, 3:13 AM
Riddhi ValechaPosted Feb 4, 2015, 2:59 AM
Thanks Burak...
I also want to know the difference between all these... I am not able to get the concept from msdn....
Also... In which situations, we must use which statement ??
Eg -For Single Sign On, we cannot use "System.Environment.UserName", as this does not work on the server.
Can you please explain or give links from where we can get this ??
Thanks a ton...
Burak SeyhanPosted Feb 3, 2015, 9:09 AM