When using windows authentication, that meanns you rely on the windows operating system and IIS server to help you perform authentication through the windows identity used by the client user(of your web application).
In order to use windows authentication, you need to make sure your web application's hosting and client user's machine meet the requirements. Generally, both the client and server machines should be in the same local network environment, and they should
be part of the same Windows domain (or trusted domain). There should exists a Domain Controller(DC) server in your environment which manage all the domain user accounts and the machines joined that domain can use the domain accounts(instead of the local user
accounts on each computer) for authentication when logon to remote machines. So make sure your current environment is ready on this. For detailed information about windows AD and domain, you can try posting in the technet "Windows Server" related forums:
vahid.ch
Member
294 Points
331 Posts
Windows Authenticate
Apr 10, 2012 06:44 AM|LINK
Hi there,I want to implement a web site which will log in via Windows Authenticate.
We have around 200 employees in our co and I dont want to log in via Forms authentication.
so no need to log in by Username and password,I want when each user wants to open a page his/her system name presents.
for instance:
Welcome Copmanyname/vahidch-pc
any idea?
mm10
Contributor
6399 Points
1184 Posts
Re: Windows Authenticate
Apr 10, 2012 07:57 AM|LINK
If you're using Windows authentication you can get the username of the logged in user like this:
WindowsIdentity.GetCurrent().Name;
You can set a label with a welcome message in the Page_Load event of a page:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Label1.text = "Welcome " + WindowsIdentity.GetCurrent().Name;
}
}
vahid.ch
Member
294 Points
331 Posts
Re: Windows Authenticate
Apr 10, 2012 08:52 AM|LINK
thanks for your responding,another problem is that:
we use Active Directory,and when I do this,it returns:
NT AUTHORITY\SYSTEM
I also cheked this code:
WindowsIdentity.GetCurrent().User.ToString();
but it return something like this:
s-0-2-3
mm10
Contributor
6399 Points
1184 Posts
Re: Windows Authenticate
Apr 10, 2012 09:13 AM|LINK
You can try HttpContext.Current.User.Identity.Name.
vahid.ch
Member
294 Points
331 Posts
Re: Windows Authenticate
Apr 10, 2012 09:33 AM|LINK
As I found out I should use "Using a Domain Users Account".
But I don't know how to do this.
Steven Cheng...
Contributor
4199 Points
548 Posts
Microsoft
Moderator
Re: Windows Authenticate
Apr 12, 2012 01:39 AM|LINK
Hi vahid.ch,
When using windows authentication, that meanns you rely on the windows operating system and IIS server to help you perform authentication through the windows identity used by the client user(of your web application).
In order to use windows authentication, you need to make sure your web application's hosting and client user's machine meet the requirements. Generally, both the client and server machines should be in the same local network environment, and they should be part of the same Windows domain (or trusted domain). There should exists a Domain Controller(DC) server in your environment which manage all the domain user accounts and the machines joined that domain can use the domain accounts(instead of the local user accounts on each computer) for authentication when logon to remote machines. So make sure your current environment is ready on this. For detailed information about windows AD and domain, you can try posting in the technet "Windows Server" related forums:
#Windows Server
http://social.technet.microsoft.com/Forums/en/category/windowsserver
and for using integrated windows authentication in ASP.NET, here are some good reference for you to understand how it works:
#Explained: Windows Authentication in ASP.NET 2.0
http://msdn.microsoft.com/en-us/library/ff647076.aspx
#How to implement Windows authentication and authorization in ASP.NET
http://support.microsoft.com/kb/323176
Feedback to us
Microsoft One Code Framework