#At file:///C:/Users/Reggie/work/connector-net/trunk-windows-auth/ based on revid:reggie.burnett@stripped
966 Reggie Burnett 2011-03-31 [merge]
Attempt to workaround changes and bugs in of the client/server protocol after WL#1054.
Probably final one. Seems to be working somehow, even with COM_CHANGE_USER.
modified:
MySql.Data/Provider/Source/NativeDriver.cs
MySql.Data/Provider/Source/SSPI.cs
MySql.Data/Tests/Source/ConnectionTests.cs
=== modified file 'MySql.Data/Provider/Source/NativeDriver.cs'
=== modified file 'MySql.Data/Provider/Source/NativeDriver.cs'
--- a/MySql.Data/Provider/Source/NativeDriver.cs 2011-03-31 17:22:29 +0000
+++ b/MySql.Data/Provider/Source/NativeDriver.cs 2011-03-31 17:23:38 +0000
@@ -486,7 +486,7 @@
}
// Do SSPI authentication handshake
- SSPI sspi = new SSPI(targetName, stream.BaseStream);
+ SSPI sspi = new SSPI(targetName, stream.BaseStream, stream.SequenceByte);
sspi.AuthenticateClient();
// read ok packet.
@@ -517,14 +517,15 @@
if (Settings.IntegratedSecurity)
{
// Append authentication method after the database name in the
- // handshake authentication packet. Omit it, if we do connection
- // reset (reset should use the same authentication method)
- if (!reset)
+ // handshake authentication packet.If we're sending CHANGE_USER
+ // also write charset number after database name prior to plugin name
+ if (reset)
{
- packet.WriteString(AuthenticationWindowsPlugin);
+ packet.WriteInteger(8, 2); // Charset number
}
+ packet.WriteString(AuthenticationWindowsPlugin);
stream.SendPacket(packet);
- AuthenticateSSPI();
+ AuthenticateSSPI(reset);
return;
}
else
=== modified file 'MySql.Data/Provider/Source/SSPI.cs'
--- a/MySql.Data/Provider/Source/SSPI.cs 2010-10-22 20:20:50 +0000
+++ b/MySql.Data/Provider/Source/SSPI.cs 2010-11-19 00:39:14 +0000
@@ -114,12 +114,14 @@
[DllImport("secur32.Dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern int DeleteSecurityContext(ref SECURITY_HANDLE pCred);
- public SSPI(string targetName, Stream stream)
+
+
+ public SSPI(string targetName, Stream stream, int seqNo)
{
this.targetName = null;
this.stream = stream;
packetHeader = new byte[4];
-
+ seq = seqNo;
}
=== modified file 'MySql.Data/Tests/Source/ConnectionTests.cs'
--- a/MySql.Data/Tests/Source/ConnectionTests.cs 2010-10-14 22:10:08 +0000
+++ b/MySql.Data/Tests/Source/ConnectionTests.cs 2010-11-19 00:39:14 +0000
@@ -72,7 +72,17 @@
#if !CF //No Security.Principal on CF
[Test]
- public void TestIntegratedSecurity()
+ public void TestIntegratedSecurityNoPooling()
+ {
+ TestIntegratedSecurity(false);
+ }
+
+ [Test]
+ public void TestIntegratedSecurityPooling()
+ {
+ TestIntegratedSecurity(true);
+ }
+ public void TestIntegratedSecurity(bool pooling)
{
@@ -141,25 +151,41 @@
// Finally, use IntegratedSecurity=true for the newly created user
string connStr = GetConnectionString(true) + ";Integrated Security=SSPI";
- using (MySqlConnection c = new MySqlConnection(connStr))
- {
- c.Open();
-
- MySqlCommand command = new MySqlCommand("SELECT 1", c);
- long ret = (long)command.ExecuteScalar();
- Assert.AreEqual(ret, 1);
-
-
- command.CommandText = "select user()";
- string user = (string)command.ExecuteScalar();
- // Check if proxy user is correct
- Assert.IsTrue(user.StartsWith("auth_windows@"));
-
- // check if mysql user is correct
- // (foo_user is mapped to current OS user)
- command.CommandText = "select current_user()";
- string currentUser = (string)command.ExecuteScalar();
- Assert.IsTrue(currentUser.StartsWith("foo_user@"));
+
+ /* If pooling is requested, we'll run test twice, with connection reset in between */
+ if (pooling)
+ {
+ connStr += ";Connection Reset=true;Pooling=true";
+ }
+ int testIterations = pooling ? 2 : 1;
+
+ int threadId = -1;
+ for (int i = 0; i < testIterations ;i++ )
+ {
+ using (MySqlConnection c = new MySqlConnection(connStr))
+ {
+ c.Open();
+ threadId = c.ServerThread;
+ MySqlCommand command = new MySqlCommand("SELECT 1", c);
+ long ret = (long)command.ExecuteScalar();
+ Assert.AreEqual(ret, 1);
+
+ command.CommandText = "select user()";
+ string user = (string)command.ExecuteScalar();
+ // Check if proxy user is correct
+ Assert.IsTrue(user.StartsWith("auth_windows@"));
+
+ // check if mysql user is correct
+ // (foo_user is mapped to current OS user)
+ command.CommandText = "select current_user()";
+ string currentUser = (string)command.ExecuteScalar();
+ Assert.IsTrue(currentUser.StartsWith("foo_user@"));
+ }
+ }
+
+ if (pooling)
+ {
+ suExecSQL("KILL " + threadId);
}
}
finally
No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
| Thread |
|---|
| • bzr commit into connector-net-trunk branch (reggie.burnett:966) WL#1054 | Reggie Burnett | 31 Mar |