Support creating & editing additional user types (#1962)

* WIP

* Fix contained user password handling

* More user related bug fixes
This commit is contained in:
Karl Burtram
2023-03-23 18:01:55 -07:00
committed by GitHub
parent 5fce03f6cf
commit c3444e5cf5
7 changed files with 224 additions and 122 deletions

View File

@@ -14,6 +14,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
namespace Microsoft.SqlTools.ServiceLayer.Utility
@@ -86,6 +87,45 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
return ss;
}
public static bool IsSecureStringsEqual(SecureString ss1, SecureString ss2)
{
IntPtr bstr1 = IntPtr.Zero;
IntPtr bstr2 = IntPtr.Zero;
try
{
bstr1 = Marshal.SecureStringToBSTR(ss1);
bstr2 = Marshal.SecureStringToBSTR(ss2);
int length1 = Marshal.ReadInt32(bstr1, -4);
int length2 = Marshal.ReadInt32(bstr2, -4);
if (length1 != length2)
{
return false;
}
for (int x = 0; x < length1; ++x)
{
byte b1 = Marshal.ReadByte(bstr1, x);
byte b2 = Marshal.ReadByte(bstr2, x);
if (b1 != b2)
{
return false;
}
}
return true;
}
finally
{
if (bstr2 != IntPtr.Zero)
{
Marshal.ZeroFreeBSTR(bstr2);
}
if (bstr1 != IntPtr.Zero)
{
Marshal.ZeroFreeBSTR(bstr1);
}
}
}
/// <summary>
/// this is the main method that is called by DropAllObjects for every object
/// in the grid