Windows Authentication with Chrome and IIS

转载,留作以后查看

Recently I was tasked at work with creating a dashboard application for use on our intranet using ASP.Net MVC. Due to the need to track some user preferences, I set this up to use Windows Authentication so I would be automatically passed the credentials from the user’s Windows session. I developed the web app and tested it using IIS express on my local machine using both Internet Explorer and Google Chrome without issue. When it came time to deploy the site to our test cluster for some user feedback, this is where I discovered an issue around Windows Authentication with Chrome and IIS (Internet Explorer still worked fine).

When pulling up the site in Chrome I was greeted with “This webpage is not available”. Clicking on the more button revealed the error code: “ERR_INVALID_AUTH_CREDENTIALS”.
 

Chrome Invalid Auth Credentials

 
 

What Didn’t Work:

I remembered reading where Chrome uses the local intranet settings from Internet Explorer so I pulled up those settings to take a look. I tried specifically adding the new site to the local intranet zone with the dialog box shown below (Internet Options -> Security Tab -> Sites -> Advanced). Unfortunately, this didn’t help. When I refreshed Chrome I still had the “ERR_INVALID_AUTH_CREDENTIALS” error.
 

Local Intranet Add Site To Zone

 
Back on the security tab in the internet options dialog, I clicked the “Custom Level” button and looked through all the settings. At the very bottom I found what looked like a promising setting under User Authentication -> Logon. By default, “Automatic logon only in Intranet zone” was selected. I changed that to the option below it that read, “Automatic logon with current user name and password”. Upon refreshing Chrome, I once again found I was still getting the “ERR_INVALID_AUTH_CREDENTIALS” error.
 

Local Intranet Security Settings

 
 
What Worked:

At this point I decided to start Googling around for some help. I found several StackOverflow questions that offered some suggestions, but none of them seemed to work. Eventually I stumbled across the suggestion of removing “Negotiate” from the enabled providers in IIS for the site. I gave it a shot, and this is what ended up solving the issue for me.

Here’s how to make the change: Navigate to your site/application in IIS and select it by clicking on it. This should show a list of options in the “features view” on the right hand side of the screen. Find “Authentication” and double click on it.
 

IIS Select Authentication

 
You should now see a list of different authentication types. Click on Windows Authentication to select it and then click on Providers in the Action section of the right hand column.
 

IIS Select Windows Auth

 
This will pop-up a dialog showing the enabled providers. I tried adjusting the negotiate provider’s priority by moving it down the list, but that didn’t seem to have any effect. Remove the “Negotiate” provider by clicking on it in the list to select it and then clicking on Remove.
 

IIS Providers Dialog

 
Click the Ok button on the dialog to close it down and then refresh your site in Chrome.

Version Information:
Google Chrome v33
Internet Explorer v11
IIS v7.5

This entry was posted in  ASP.Net MVC and tagged  ASP.Net MVCChromeIISWindows Authentication. Bookmark the  permalink.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: JDBC连接SQL Server并使用Windows身份验证可以通过以下步骤实现: 1. 下载Microsoft JDBC驱动程序并将其添加到您的项目中。 2. 在Java代码中,使用以下代码片段来连接到SQL Server: ```java String connectionUrl = "jdbc:sqlserver://localhost:1433;" + "databaseName=mydatabase;integratedSecurity=true;"; try (Connection con = DriverManager.getConnection(connectionUrl)) { // Code here for executing SQL statements } ``` 其中,`localhost`是SQL Server所在的主机名或IP地址,`1433`是SQL Server的默认端口号,`mydatabase`是您要连接的数据库名称。`integratedSecurity=true`表示使用Windows身份验证进行身份验证。 3. 在SQL Server上配置Windows身份验证。在SQL Server Management Studio中,右键单击服务器名称,选择“属性”->“安全性”,将“身份验证方式”设置为“Windows身份验证”。 4. 确保Java应用程序执行此代码的用户具有访问SQL Server的权限。 希望这能帮助到您! ### 回答2: JDBC是一种用于在Java程序中访问数据库的API。而SQL Server是微软提供的一种关系型数据库管理系统。通过JDBC连接到SQL Server数据库时,可以选择使用Windows身份验证。 使用Windows身份验证,意味着可以使用当前操作系统登录用户的身份来连接数据库,省去了在程序中明文存储用户名和密码的步骤。这样可以提高数据库的安全性。同时,也可以方便地与Windows域进行集成,管理和验证用户身份。 要使用JDBC连接到SQL Server数据库并使用Windows身份验证,首先需要在数据库服务器上设置为允许Windows身份验证。然后,在Java代码中指定相应的JDBC连接URL和驱动名称,以便使用Windows身份验证连接到SQL Server数据库。 JDBC连接URL的格式通常为:jdbc:sqlserver://[服务器名称]:[端口号];databaseName=[数据库名称];integratedSecurity=true;。 接下来,我们需要确保Java代码中导入了正确的JDBC驱动程序。可以从Microsoft官方网站上下载适用于SQL Server的JDBC驱动程序,并将其添加到项目的类路径中。 在编写Java代码时,可以使用java.sql包中的类和方法来建立和执行与数据库的连接。根据需要,可以使用Statement、PreparedStatement或CallableStatement执行SQL查询或更新。 总而言之,通过JDBC和Windows身份验证,可以方便地在Java程序中连接到SQL Server数据库,并以更安全和便捷的方式进行数据操作。 ### 回答3: JDBC是一种Java数据库连接的标准,用于连接和操作不同的数据库。 SQL Server是一种关系型数据库管理系统,是由微软开发的。 Windows AuthenticationWindows身份验证)是SQL Server中的一种身份验证方式。当SQL Server安装在Windows操作系统上时,可以选择使用Windows身份验证来让用户登录和访问数据库。Windows身份验证会使用Windows操作系统的用户凭据来认证用户身份,而不是使用SQL Server的用户名和密码。 JDBC可以通过相应的数据库驱动程序来连接和访问SQL Server数据库。对于使用Windows身份验证的SQL Server数据库,JDBC需要使用特定的驱动程序来实现Windows身份验证的支持。 在使用JDBC连接SQL Server数据库时,需要在连接字符串中指定Windows身份验证的相关参数。比如,可以使用"integratedSecurity=true"来启用Windows身份验证,还可以使用"domain=xxx"和"user=xxx"来指定用户所在的域和用户名。 使用Windows身份验证连接SQL Server数据库有以下几个优势: 1. 方便:使用Windows系统的用户凭据登录数据库,无需额外的用户名和密码。 2. 安全:Windows系统的用户凭据被用于认证用户身份,保证了数据的安全性。 3. 统一管理:使用Windows身份验证可以与组织的域控制器进行集成,方便统一管理用户和权限。 总之,JDBC可以通过特定的驱动程序支持SQL Server的Windows身份验证,提供了方便、安全和统一管理的好处。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值