/// <summary> /// Checks if the given privilege is enabled. This does not tell you whether or not it /// is possible to get a privilege- most held privileges are not enabled by default. /// </summary> internal static bool IsPrivilegeEnabled(SafeCloseHandle token, Privileges privilege) { LUID luid = LookupPrivilegeValue(privilege.ToString()); var luidAttributes = new LUID_AND_ATTRIBUTES { Luid = luid, Attributes = SE_PRIVILEGE_ENABLED }; var set = new PRIVILEGE_SET { Control = PRIVILEGE_SET_ALL_NECESSARY, PrivilegeCount = 1, Privilege = new[] { luidAttributes } }; bool result; if (!Private.PrivilegeCheck(token, ref set, out result)) { int error = Marshal.GetLastWin32Error(); throw GetIoExceptionForError(error, privilege.ToString()); } return(result); }
/// <summary> /// Checks if the given privilege is enabled. This does not tell you whether or not it /// is possible to get a privilege- most held privileges are not enabled by default. /// </summary> public static bool IsPrivilegeEnabled(SafeTokenHandle token, Privileges privilege) { LUID luid = LookupPrivilegeValue(privilege.ToString()); var luidAttributes = new LUID_AND_ATTRIBUTES { Luid = luid, Attributes = (uint)PrivilegeAttributes.SE_PRIVILEGE_ENABLED }; var set = new PRIVILEGE_SET { Control = PRIVILEGE_SET_ALL_NECESSARY, PrivilegeCount = 1, Privilege = new[] { luidAttributes } }; bool result; if (!Direct.PrivilegeCheck(token, ref set, out result)) { throw ErrorHelper.GetIoExceptionForLastError(privilege.ToString()); } return(result); }
public override string ToString() { StringBuilder sb = new StringBuilder("Table("); sb.Append("TableName: "); sb.Append(TableName); sb.Append(",DbName: "); sb.Append(DbName); sb.Append(",Owner: "); sb.Append(Owner); sb.Append(",CreateTime: "); sb.Append(CreateTime); sb.Append(",LastAccessTime: "); sb.Append(LastAccessTime); sb.Append(",Retention: "); sb.Append(Retention); sb.Append(",Sd: "); sb.Append(Sd == null ? "<null>" : Sd.ToString()); sb.Append(",PartitionKeys: "); sb.Append(PartitionKeys); sb.Append(",Parameters: "); sb.Append(Parameters); sb.Append(",ViewOriginalText: "); sb.Append(ViewOriginalText); sb.Append(",ViewExpandedText: "); sb.Append(ViewExpandedText); sb.Append(",TableType: "); sb.Append(TableType); sb.Append(",Privileges: "); sb.Append(Privileges == null ? "<null>" : Privileges.ToString()); sb.Append(",Temporary: "); sb.Append(Temporary); sb.Append(")"); return(sb.ToString()); }
public void AddUser(string userName, string repositoryName, Privileges permission) { try { using (var stream = this[repositoryName]) { if(stream.Length == 0) { stream.Dispose(); File.Delete(Path(_filePath, repositoryName)); return; } var repository = XElement.Load(stream); var group = repository.Elements(GroupType).First( g => g.Attribute("perm").Value == permission.ToString()); if (group.Elements().Any(u => u.Attribute("name").Value == userName)) return; group.Add(User(userName)); stream.SetLength(0); repository.Save(stream); stream.Flush(); } } catch (IOException) { Thread.Sleep(Window); AddUser(userName, repositoryName, permission); } }
protected override void GetEventData(IDictionary <string, object> data) { data["granter"] = Granter; data["grantee"] = Grantee; data["object"] = ObjectName.ToString(); data["privileges"] = Privileges.ToString(SqlPrivileges.Resolver); data["withOption"] = WithGrantOption; }
public override string ToString() { StringBuilder sb = new StringBuilder("GrantRevokePrivilegeRequest("); sb.Append("RequestType: "); sb.Append(RequestType); sb.Append(",Privileges: "); sb.Append(Privileges == null ? "<null>" : Privileges.ToString()); sb.Append(",RevokeGrantOption: "); sb.Append(RevokeGrantOption); sb.Append(")"); return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder("Database("); sb.Append("Name: "); sb.Append(Name); sb.Append(",Description: "); sb.Append(Description); sb.Append(",LocationUri: "); sb.Append(LocationUri); sb.Append(",Parameters: "); sb.Append(Parameters); sb.Append(",Privileges: "); sb.Append(Privileges == null ? "<null>" : Privileges.ToString()); sb.Append(",OwnerName: "); sb.Append(OwnerName); sb.Append(",OwnerType: "); sb.Append(OwnerType); sb.Append(")"); return(sb.ToString()); }
private bool RoleHasPermission(Role r, Privileges privilege) { return SecurityUtil.ExistOnCurrentWorkstation(privilege) && (from p in r.Permissions where p.Name == privilege.ToString() select p).Count() > 0; }
public virtual string RevokePrivilege(string username, Privileges privilege, string dbName) { return(String.Format(QueryStatements.RevokePrivilege, privilege.ToString().ToUpper(), dbName, username)); }
private static XElement Group(Privileges privileges) { var group = new XElement(GroupType); group.SetAttributeValue("perm", privileges.ToString()); return group; }
/// <summary> /// Checks if the given privilege is enabled. This does not tell you whether or not it /// is possible to get a privilege- most held privileges are not enabled by default. /// </summary> internal static bool IsPrivilegeEnabled(SafeCloseHandle token, Privileges privilege) { LUID luid = LookupPrivilegeValue(privilege.ToString()); var luidAttributes = new LUID_AND_ATTRIBUTES { Luid = luid, Attributes = SE_PRIVILEGE_ENABLED }; var set = new PRIVILEGE_SET { Control = PRIVILEGE_SET_ALL_NECESSARY, PrivilegeCount = 1, Privilege = new[] { luidAttributes } }; bool result; if (!Private.PrivilegeCheck(token, ref set, out result)) { int error = Marshal.GetLastWin32Error(); throw GetIoExceptionForError(error, privilege.ToString()); } return result; }
private bool RoleHasPermission(Role r, Privileges privilege) { return(SecurityUtil.ExistOnCurrentWorkstation(privilege) && (from p in r.Permissions where p.Name == privilege.ToString() select p).Count() > 0); }
private bool RoleHasPermission(Role r, Privileges privilege) { return(PrivilegeBelongsToCurrentWorkstation(privilege) && (from p in r.Permissions where p.Name == privilege.ToString() select p).Count() > 0); }