Getting a list of Tasks that belong to a Role from Azman

Posted by Steven on Stack Overflow See other posts from Stack Overflow or by Steven
Published on 2009-10-26T22:38:42Z Indexed on 2010/05/03 9:18 UTC
Read the original article Hit count: 267

Filed under:
|
|
|

I'm using the AZROLESLib which is from the COM references "azroles 1.0 Type Library" and I am trying to create a list of the designated tasks for each role that I have currently set in my authorization manager but when I loop through the tasks for the role, I get the role name.

I've looked all around but couldn't find anything that would help.

Here's what I got currently (It's not super pretty but i'm just trying to get it working at the moment).

AzAuthorizationStoreClass AzManStore = new AzAuthorizationStoreClass();
AzManStore.Initialize(0, ConfigurationManager.ConnectionStrings["AzManStore"].ConnectionString, null);
IAzApplication azApp = AzManStore.OpenApplication("StoreName", null);
StringBuilder output = new StringBuilder();
Array tasks = null;
foreach (IAzRole currentRole in azApp.Roles)
{
    output.Append(currentRole.Name + "<br />");

    tasks = (Array)currentRole.Tasks;
    foreach (object ob in tasks)
    {
        output.Append("&nbsp;&nbsp; -" + ob.ToString() + "<br />");
    }
}             
return output.ToString();

What comes out is:

  • Administrator -Administrator

  • Account Manager -Account Manager

  • Corporate Marketing Specialist -Corporate Marketing Specialist

  • General Employee -General Employee

  • Marketing Manager -Marketing Manager

  • Regional Marketing Specialist -Regional Marketing Specialist

  • Sales Manager -Sales Manager

  • Webmaster -Webmaster

but what should come out is something like:

  • Webmaster
    • Websites Maintain
    • News Maintain
    • Events Maintain
    • Reports Read


Thanks in advance.

© Stack Overflow or respective owner

Related posts about azman

Related posts about c#