public void RevokeFromUser(string userName, Grant grant) { if (String.IsNullOrEmpty(userName)) { throw new ArgumentNullException("userName"); } try { RevokeAllGrantsFromUser(grant.ObjectType, grant.ObjectName, grant.GranterName, userName, grant.WithOption); } finally { ClearUserGrantsCache(userName, grant.ObjectType, grant.ObjectName, grant.WithOption, false); } }
public void Grant(Grant grant) { if (grant == null) { throw new ArgumentNullException("grant"); } var objectType = grant.ObjectType; var objectName = grant.ObjectName; var privileges = grant.Privileges; Privileges oldPrivs = GetPrivileges(grant.Grantee, objectType, objectName, grant.WithOption); privileges |= oldPrivs; if (!oldPrivs.Equals(privileges)) { UpdateUserGrants(objectType, objectName, grant.GranterName, grant.Grantee, privileges, grant.WithOption); } }
public static void GrantToGroupOn(this IQuery query, DbObjectType objectType, ObjectName objectName, string groupName, Privileges privileges, bool withOption = false) { if (SystemGroups.IsSystemGroup(groupName)) { throw new InvalidOperationException("Cannot grant to a system group."); } if (!query.UserCanManageGroups()) { throw new MissingPrivilegesException(query.UserName(), new ObjectName(groupName)); } if (!query.ObjectExists(objectType, objectName)) { throw new ObjectNotFoundException(objectName); } var granter = query.UserName(); var grant = new Grant(privileges, objectName, objectType, granter, withOption); query.Direct().PrivilegeManager().GrantToGroup(groupName, grant); }
public static void GrantToUserOn(this IQuery query, DbObjectType objectType, ObjectName objectName, string grantee, Privileges privileges, bool withOption = false) { if (String.Equals(grantee, User.SystemName)) // The @SYSTEM user does not need any other { return; } if (!query.ObjectExists(objectType, objectName)) { throw new ObjectNotFoundException(objectName); } if (!query.UserHasGrantOption(objectType, objectName, privileges)) { throw new MissingPrivilegesException(query.UserName(), objectName, privileges); } var granter = query.UserName(); var grant = new Grant(privileges, objectName, objectType, granter, withOption); query.Direct().PrivilegeManager().GrantToUser(grantee, grant); }
public void GrantToUser(string userName, Grant grant) { if (String.IsNullOrEmpty(userName)) { throw new ArgumentNullException("userName"); } if (grant == null) { throw new ArgumentNullException("grant"); } var objectType = grant.ObjectType; var objectName = grant.ObjectName; var privileges = grant.Privileges; Privileges oldPrivs = GetUserPrivileges(userName, objectType, objectName, grant.WithOption); privileges |= oldPrivs; if (!oldPrivs.Equals(privileges)) { UpdateUserGrants(objectType, objectName, grant.GranterName, userName, privileges, grant.WithOption); } }
public static void GrantToUserOn(this IQueryContext context, DbObjectType objectType, ObjectName objectName, string grantee, Privileges privileges, bool withOption = false) { if (String.Equals(grantee, User.SystemName)) // The @SYSTEM user does not need any other return; if (!context.ObjectExists(objectType, objectName)) throw new ObjectNotFoundException(objectName); if (!context.UserHasGrantOption(objectType, objectName, privileges)) throw new MissingPrivilegesException(context.UserName(), objectName, privileges); var granter = context.UserName(); var grant = new Grant(privileges, objectName, objectType, granter, withOption); context.ForSystemUser().PrivilegeManager().GrantToUser(grantee, grant); }
public static void GrantToGroupOn(this IQueryContext context, DbObjectType objectType, ObjectName objectName, string groupName, Privileges privileges, bool withOption = false) { if (SystemGroups.IsSystemGroup(groupName)) throw new InvalidOperationException("Cannot grant to a system group."); if (!context.UserCanManageGroups()) throw new MissingPrivilegesException(context.UserName(), new ObjectName(groupName)); if (!context.ObjectExists(objectType, objectName)) throw new ObjectNotFoundException(objectName); var granter = context.UserName(); var grant = new Grant(privileges, objectName, objectType, granter, withOption); context.ForSystemUser().PrivilegeManager().GrantToGroup(groupName, grant); }
public void Revoke(Grant grant) { RevokeAllGrantsFrom(grant.ObjectType, grant.ObjectName, grant.GranterName, grant.Grantee, grant.WithOption); }
public void RevokeFromGroup(string groupName, Grant grant) { throw new NotImplementedException(); }
public void GrantToGroup(string groupName, Grant grant) { throw new NotImplementedException(); }
public void Grant(Grant grant) { if (grant == null) throw new ArgumentNullException("grant"); var objectType = grant.ObjectType; var objectName = grant.ObjectName; var privileges = grant.Privileges; Privileges oldPrivs = GetPrivileges(grant.Grantee, objectType, objectName, grant.WithOption); privileges |= oldPrivs; if (!oldPrivs.Equals(privileges)) UpdateUserGrants(objectType, objectName, grant.GranterName, grant.Grantee, privileges, grant.WithOption); }