Answered by:
how to config window Active Directory authentication by loading home page before window security login screen pop up ?

Question
-
User887006070 posted
I am using sql server 2008r2 and IIS 7.5. i am building a website to enable Windows Authentication within an ASP.NET Application, with “Integrated Windows Authentication” . But the problem is when i click the url "10.10.10.10: 123", it prompt window security login screen to type in a/c & pw instead of loading home page of url. I have added default document "home.aspx" do someone has solution to fix it? Thanks!!
<configuration>
<connectionStrings>
<add name="ADConnectionString" connectionString="LDAP://domainName/DC=domainName" /><add connectionString="Data Source=xxx ;Initial Catalog=xxx ;Persist Security Info=false; Integrated Security=SSPI;Trusted_Connection=True; Pooling=True" name="abc" providerName="System.Data.SqlClient" />
<system.web>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
</httpHandlers>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
</assemblies>
<buildProviders >
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
</compilation><authentication mode="Windows" >
</authentication>
<membership defaultProvider="AspNetSqlProfileProvider" userIsOnlineTimeWindow="10">
<providers>
<add name="AspNetSqlProfileProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="taisangrent_sql" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<authorization>
<allow users="*" />
</authorization>
<identity impersonate="true" />
<profile >
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager><sessionState timeout="600" />
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
<defaultDocument enabled="true">
<files>
<add value="home.aspx" />
</files>
</defaultDocument>
</system.webServer><appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="10000" />
</appSettings>
</configuration>Thursday, November 26, 2015 7:30 AM
Answers
-
User614698185 posted
Hi bbqwings,
I think you could modify your code like below:
<configuration> <system.web> <authentication mode="Forms"> <forms loginUrl="logon.aspx" name="adAuthCookie" timeout="10" path="/" > </forms> </authentication> <authorization> <deny users="?" /> <allow users="*" /> </authorization> <identity impersonate="true" /> </system.web> </configuration>
For more information, please see: https://support.microsoft.com/en-us/kb/316748
Best Regards,
Candice Zhou
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, December 1, 2015 9:18 AM
All replies
-
User753101303 posted
Hi,
Likely because ALL the application is configured to allow authenticated users. You could use https://msdn.microsoft.com/library/b6x6shw7(v=vs.100).aspx and see first sample. It allows to tell that a particular page is available to anonymous users (pay also attention to possible js, images etc.. resources that could be loaded by this page)
So you would have something such as:
<location path="home.aspx"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location>
Thursday, November 26, 2015 8:59 AM -
User887006070 posted
thanks for reply, but when i added the code you suggested , the following error appears:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
Thursday, November 26, 2015 9:58 AM -
User753101303 posted
So it seems you are past your first issue. Now the page likely try to runs but the db connection string is not correct.
Is this the full message? Make sure the server mentioned in Data Source is reachable from your web server (no firewall issue etc..., if using SQL Server Express you have to explicitely allow connections from other machines etc...). For now it seems your db server can't be reached.
Then you are using integrated security which could cause another issue (you'll use the authenticated user to connect to SQL Server but it requires some additional configuration as far as I know). Make sure first this is really the option you want (in short do you need to use SQL Server side user based permissions?)
Thursday, November 26, 2015 12:12 PM -
User614698185 posted
Hi bbqwings,
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.Based on your error, you could refer to the following links to resolve it:
Best Regards,
Candice Zhou
Friday, November 27, 2015 8:58 AM -
User887006070 posted
sorry, i need to state clear that my original web.config works, but when i take suggestions from PraticeSo, it appear to network-related problem, i think it is not an issue about the connections to the SQL SERVER, Thanks for attention
<location path="home.aspx"> <system.web> <authorization> <allow users="?"/> </authorization> </system.web> </location>
Monday, November 30, 2015 2:26 AM -
User614698185 posted
Hi bbqwings,
I think you could modify your code like below:
<configuration> <system.web> <authentication mode="Forms"> <forms loginUrl="logon.aspx" name="adAuthCookie" timeout="10" path="/" > </forms> </authentication> <authorization> <deny users="?" /> <allow users="*" /> </authorization> <identity impersonate="true" /> </system.web> </configuration>
For more information, please see: https://support.microsoft.com/en-us/kb/316748
Best Regards,
Candice Zhou
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, December 1, 2015 9:18 AM