September 15, 2009

Using the AzMan Helper Classes III

We have seen how to add a store,create an application, add an operation, add tasks, create roles, add application groups, and add users via SID or UPN to groups in AzMan using C#. All of these are available here.

Here is the third post regarding the usage of these helper classes:
public void AddMemberToRole(string storeUrl, string applicationName, string roleName, string memberSID)
{
IAzApplication app = ApplicationHelper.GetApplication(storeUrl, applicationName);
IAzRole role = RoleHelper.GetRole(app, roleName);
RoleMemberHelper.AddRoleMember(role, memberSID);
}
public void RemoveMemberFromRole(string storeUrl, string applicationName, string roleName, string memberSID)
{
IAzApplication app = ApplicationHelper.GetApplication(storeUrl, applicationName);
IAzRole role = RoleHelper.GetRole(app, roleName);
RoleMemberHelper.RemoveRoleMember(role, memberSID);
}

//add by UPN
public void AddMemberNameToRole(string storeUrl, string applicationName, string roleName, string memberName)
{
IAzApplication app = ApplicationHelper.GetApplication(storeUrl, applicationName);
IAzRole role = RoleHelper.GetRole(app, roleName);
RoleMemberHelper.AddRoleMemberName(role, memberName);
}

public void RemoveMemberNameFromRole(string storeUrl, string applicationName, string roleName, string memberName)
{
IAzApplication app = ApplicationHelper.GetApplication(storeUrl, applicationName);
IAzRole role = RoleHelper.GetRole(app, roleName);
RoleMemberHelper.RemoveRoleMemberName(role, memberName);
}

//Get a list of role member names for a specified role
public string[] GetRoleMemberNames(string storeUrl, string applicationName, string roleName)
{
IAzApplication app = ApplicationHelper.GetApplication(storeUrl, applicationName);
IAzRole role = RoleHelper.GetRole(app, roleName);
return RoleMemberHelper.GetRoleMemberNames(role);
}

public bool IsRoleMemberNameExists(string storeUrl, string applicationName, string roleName, string memberName)
{
IAzApplication app = ApplicationHelper.GetApplication(storeUrl, applicationName);
IAzRole role = RoleHelper.GetRole(app, roleName);
return RoleMemberHelper.IsRoleMemberNameExists(role, memberName);
}

//Get a list of role member SIDs for a specified role
public string[] GetRoleMembers(string storeUrl, string applicationName, string roleName)
{
IAzApplication app = ApplicationHelper.GetApplication(storeUrl, applicationName);
IAzRole role = RoleHelper.GetRole(app, roleName);
return RoleMemberHelper.GetRoleMembers(role);
}

public bool IsRoleMemberExists(string storeUrl, string applicationName, string roleName, string memberSID)
{
IAzApplication app = ApplicationHelper.GetApplication(storeUrl, applicationName);
IAzRole role = RoleHelper.GetRole(app, roleName);
return RoleMemberHelper.IsRoleMemberExists(role, memberSID);
}

No comments:

Post a Comment