mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
User handler bugs WIP (#1925)
This commit is contained in:
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Microsoft.SqlServer.Management.Common;
|
using Microsoft.SqlServer.Management.Common;
|
||||||
@@ -199,7 +198,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Security
|
|||||||
SupportSQLAuthentication = true,
|
SupportSQLAuthentication = true,
|
||||||
Languages = new string[] { },
|
Languages = new string[] { },
|
||||||
Schemas = currentUserPrototype.SchemaNames.ToArray(),
|
Schemas = currentUserPrototype.SchemaNames.ToArray(),
|
||||||
Logins = LoadSqlLogins(serverConnection),
|
Logins = DatabaseUtils.LoadSqlLogins(serverConnection),
|
||||||
DatabaseRoles = currentUserPrototype.DatabaseRoleNames.ToArray()
|
DatabaseRoles = currentUserPrototype.DatabaseRoleNames.ToArray()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -400,36 +399,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Security
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string[] LoadSqlLogins(ServerConnection serverConnection)
|
|
||||||
{
|
|
||||||
return LoadItems(serverConnection, "Server/Login");
|
|
||||||
}
|
|
||||||
|
|
||||||
private string[] LoadItems(ServerConnection serverConnection, string urn)
|
|
||||||
{
|
|
||||||
List<string> items = new List<string>();
|
|
||||||
Request req = new Request();
|
|
||||||
req.Urn = urn;
|
|
||||||
req.ResultType = ResultType.IDataReader;
|
|
||||||
req.Fields = new string[] { "Name" };
|
|
||||||
|
|
||||||
Enumerator en = new Enumerator();
|
|
||||||
using (IDataReader reader = en.Process(serverConnection, req).Data as IDataReader)
|
|
||||||
{
|
|
||||||
if (reader != null)
|
|
||||||
{
|
|
||||||
string name;
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
// Get the permission name
|
|
||||||
name = reader.GetString(0);
|
|
||||||
items.Add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return items.ToArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class UserActions : ManagementActionBase
|
internal class UserActions : ManagementActionBase
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using Microsoft.SqlServer.Management.Smo;
|
|||||||
using Microsoft.SqlTools.ServiceLayer.Management;
|
using Microsoft.SqlTools.ServiceLayer.Management;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security;
|
using System.Security;
|
||||||
|
|
||||||
@@ -245,5 +246,36 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
|
|||||||
dataContainer.Server.ResourceGovernor.Alter();
|
dataContainer.Server.ResourceGovernor.Alter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string[] LoadSqlLogins(ServerConnection serverConnection)
|
||||||
|
{
|
||||||
|
return LoadItems(serverConnection, "Server/Login");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string[] LoadItems(ServerConnection serverConnection, string urn)
|
||||||
|
{
|
||||||
|
List<string> items = new List<string>();
|
||||||
|
Request req = new Request();
|
||||||
|
req.Urn = urn;
|
||||||
|
req.ResultType = ResultType.IDataReader;
|
||||||
|
req.Fields = new string[] { "Name" };
|
||||||
|
|
||||||
|
Enumerator en = new Enumerator();
|
||||||
|
using (IDataReader reader = en.Process(serverConnection, req).Data as IDataReader)
|
||||||
|
{
|
||||||
|
if (reader != null)
|
||||||
|
{
|
||||||
|
string name;
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
// Get the permission name
|
||||||
|
name = reader.GetString(0);
|
||||||
|
items.Add(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items.Sort();
|
||||||
|
return items.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user