One of the cool things is that you can add a member to a role by a SID. This though has to be done via code. Below you can find how to ao a bunch of this via SIDs...the helper class shows how you can do the same thing with UPN as well:
public static void AddRoleMember(IAzRole role, string memberSID)Now let's remove that member by SID from the role
{
if (memberSID == null || memberSID.Length == 0)
{
throw new ArgumentNullException("memberSID", "Member SID can not be null or empty.");
}
if (role == null)
{
throw new ArgumentNullException("role", "Role can not be null.");
}
role.AddMember(memberSID, null);
role.Submit(0, null);
}
public static void RemoveRoleMember(IAzRole role, string memberSID)How about returning true if role member SID exists?
{
if (memberSID == null || memberSID.Length == 0)
{
throw new ArgumentNullException("memberSID", "Member SID can not be null or empty.");
}
if (role == null)
{
throw new ArgumentNullException("role", "Role can not be null.");
}
role.DeleteMember(memberSID, null);
role.Submit(0, null);
}
public static bool IsRoleMemberExists(IAzRole role, string memberSID)
{
if (memberSID == null || memberSID.Length == 0)
{
throw new ArgumentNullException("memberSID", "Member SID can not be null or empty.");
}
if (role == null)
{
throw new ArgumentNullException("role", "Role can not be null.");
}
foreach (string sid in GetRoleMemberNames(role))
{
if (String.Compare(memberSID, sid) == 0)
{
return true;
}
}
return false;
}
No comments:
Post a Comment