顯示具有 Authorization 標籤的文章。 顯示所有文章
顯示具有 Authorization 標籤的文章。 顯示所有文章

2014年7月13日 星期日

[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] bundeling & minification


I converted my entire Web Forms Web Site project (200+ pages) to use bundeling & minification and every page works perfectly except my login screen. The resources get registered fine if I navigate to the login page but if I refresh it, all resources are
unrecognized by the browser as if they were never included even though if I look at the source, they are there.


I fired up the network profiler in IE11 and on a single refresh I get these 3 requests:


1. http://dev/ArgoWeb/Login.aspx?ReturnUrl=%2fArgoweb 

2. /ArgoWeb/bundles/jquery?v=5LT0ASbM4iSwzp2VLfw4Xo23UDm08wjTCtJEL6FxlNc1

3. /ArgoWeb/Login.aspx?ReturnUrl=%2fArgoWeb%2fbundles%2fjquery%3fv%3d5LT0ASbM4iSwzp2VLfw4Xo23UDm08wjTCtJEL6FxlNc1&v=5LT0ASbM4iSwzp2VLfw4Xo23UDm08wjTCtJEL6FxlNc1


(1) is the login page itself. (2) it the bundle included in the page. But request (3) seems to be triggered by the bundle URI not having access, which triggers the login page again. Stepped through the code behind and the login page indeed gets hit twice,
which it shouldn't. I think this is where the problem is. Are the virtual bundeling paths created by the optimization package supposed to be behind the authentication wall? If so how do we use them before the user logs in?


I suspect this is a bug in the optimization pack because this failure only occurs on a manual page refresh not an initial render. Wonder if this is because bundeling is only a first class citizen to MVC and hasn't been tested much with Web Forms.



I figured it out, so here is the solution if others have this problem. You must add this in your web.config making sure the path matches your bundling path.


    






This exempts the virtual directory created by the bundleing and minification framework from requiring forms authentication. I still think its a bug that the framework doesn't do this or does it partially. If bundeling is turned off, the script and CSS includes
ARE exempted, so why not when its on?


[RESOLVED] bundeling & minification


I converted my entire Web Forms Web Site project (200+ pages) to use bundeling & minification and every page works perfectly except my login screen. The resources get registered fine if I navigate to the login page but if I refresh it, all resources are
unrecognized by the browser as if they were never included even though if I look at the source, they are there.


I fired up the network profiler in IE11 and on a single refresh I get these 3 requests:


1. http://dev/ArgoWeb/Login.aspx?ReturnUrl=%2fArgoweb 

2. /ArgoWeb/bundles/jquery?v=5LT0ASbM4iSwzp2VLfw4Xo23UDm08wjTCtJEL6FxlNc1

3. /ArgoWeb/Login.aspx?ReturnUrl=%2fArgoWeb%2fbundles%2fjquery%3fv%3d5LT0ASbM4iSwzp2VLfw4Xo23UDm08wjTCtJEL6FxlNc1&v=5LT0ASbM4iSwzp2VLfw4Xo23UDm08wjTCtJEL6FxlNc1


(1) is the login page itself. (2) it the bundle included in the page. But request (3) seems to be triggered by the bundle URI not having access, which triggers the login page again. Stepped through the code behind and the login page indeed gets hit twice,
which it shouldn't. I think this is where the problem is. Are the virtual bundeling paths created by the optimization package supposed to be behind the authentication wall? If so how do we use them before the user logs in?


I suspect this is a bug in the optimization pack because this failure only occurs on a manual page refresh not an initial render. Wonder if this is because bundeling is only a first class citizen to MVC and hasn't been tested much with Web Forms.



I figured it out, so here is the solution if others have this problem. You must add this in your web.config making sure the path matches your bundling path.


    






This exempts the virtual directory created by the bundleing and minification framework from requiring forms authentication. I still think its a bug that the framework doesn't do this or does it partially. If bundeling is turned off, the script and CSS includes
ARE exempted, so why not when its on?


[RESOLVED] bundeling & minification


I converted my entire Web Forms Web Site project (200+ pages) to use bundeling & minification and every page works perfectly except my login screen. The resources get registered fine if I navigate to the login page but if I refresh it, all resources are
unrecognized by the browser as if they were never included even though if I look at the source, they are there.


I fired up the network profiler in IE11 and on a single refresh I get these 3 requests:


1. http://dev/ArgoWeb/Login.aspx?ReturnUrl=%2fArgoweb 

2. /ArgoWeb/bundles/jquery?v=5LT0ASbM4iSwzp2VLfw4Xo23UDm08wjTCtJEL6FxlNc1

3. /ArgoWeb/Login.aspx?ReturnUrl=%2fArgoWeb%2fbundles%2fjquery%3fv%3d5LT0ASbM4iSwzp2VLfw4Xo23UDm08wjTCtJEL6FxlNc1&v=5LT0ASbM4iSwzp2VLfw4Xo23UDm08wjTCtJEL6FxlNc1


(1) is the login page itself. (2) it the bundle included in the page. But request (3) seems to be triggered by the bundle URI not having access, which triggers the login page again. Stepped through the code behind and the login page indeed gets hit twice,
which it shouldn't. I think this is where the problem is. Are the virtual bundeling paths created by the optimization package supposed to be behind the authentication wall? If so how do we use them before the user logs in?


I suspect this is a bug in the optimization pack because this failure only occurs on a manual page refresh not an initial render. Wonder if this is because bundeling is only a first class citizen to MVC and hasn't been tested much with Web Forms.



I figured it out, so here is the solution if others have this problem. You must add this in your web.config making sure the path matches your bundling path.


    






This exempts the virtual directory created by the bundleing and minification framework from requiring forms authentication. I still think its a bug that the framework doesn't do this or does it partially. If bundeling is turned off, the script and CSS includes
ARE exempted, so why not when its on?