windows身份验证问题

zi8p0yeb  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(524)

正在尝试通过运行在linux计算机上的java应用程序的windows身份验证连接到ms sql server。连接字符串:
jdbc:sqlserver用法:/192.168.1.50\sqlexpress:1433;databasename=mydata;integratedsecurity=true;authenticationscheme=javakerberos
出现连接错误:

com.microsoft.sqlserver.jdbc.SQLServerException: Integrated authentication failed. ClientConnectionId:42aee675-fd0d-489e-af73-574ae5c304fa
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2670) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.KerbAuthentication.intAuthInit(KerbAuthentication.java:131) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.KerbAuthentication.GenerateClientContext(KerbAuthentication.java:399) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4306) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3409) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:85) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3373) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7344) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2713) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2261) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077) ~[mssql-jdbc-6.4.0.jre8.jar:?]

如何理解这个错误以及如何修复它?
升级版
如果我移除 authenticationScheme=JavaKerberos 具体如下:

jdbc:sqlserver://192.168.1.50\SQLEXPRESS:1433;DatabaseName=MyData;integratedSecurity=true;

我有个错误:

java.sql.SQLException: No suitable driver found for
       at java.sql.DriverManager.getConnection(DriverManager.java:689) ~[?:1.8.0_171]
       at java.sql.DriverManager.getConnection(DriverManager.java:247) ~[?:1.8.0_171]

升级版2
离开 authenticationScheme=JavaKerberos 以及移除 integratedSecurity=true 具体如下:

jdbc:sqlserver://192.168.1.50\SQLEXPRESS:1433;DatabaseName=MyData;authenticationScheme=JavaKerberos

给出错误:

com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'myuser'. ClientConnectionId:42aee675-fd0d-489e-af73-574ae5c304fa
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:259) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:256) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:108) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4548) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3409) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:85) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3373) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7344) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2713) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2261) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:623) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at java.sql.DriverManager.getConnection(DriverManager.java:664) ~[?:1.8.0_171]
        at java.sql.DriverManager.getConnection(DriverManager.java:247) ~[?:1.8.0_171]
pgccezyw

pgccezyw1#

运行在linux机器上的应用程序,该计算机是否加入了windows域?
如果没有,则可能需要使用sql身份验证:

jdbc:sqlserver://192.168.1.50\SQLEXPRESS;user=MyUserName;password=*****;

否则,这一次尝试没有 authenticationScheme=JavaKerberos 和指定的默认端口:

jdbc:sqlserver://192.168.1.50\SQLEXPRESS;DatabaseName=MyData;integratedSecurity=true;

相关问题