I have this simple code which loops through all the apps in Azman and all their roles. It works great when I have no users assigned to the Roles. But the moment I assign users (2 of the roles have like 7000 users), the app hangs in foreach(IAzRole in _azApp.Roles) code...basically the moment you access the Roles collection it hangs and takes like 40 minutes to come out of it. This is totally unacceptable. Can anyone point me to a solution ? All I want is the list of role assignment names, why is the role assignments slowing this down...?
PS: All my users are in ADAM and Azman store is in ADAM as well. I have also tried looping through IAzTasks (roledefinition=1), but that is slow too.
public override string[] GetAllRoles()
{
List<string> rolesList = new List<string>();
foreach (IAzApplication2 _azApp in AZManStore.Applications)
{
foreach (IAzRole role in _azApp.Roles)
{
//Weird that Roles are retrieved using tasks collection
if (!rolesList.Exists(delegate(string x) { return x == role.Name; }))
rolesList.Add(role.Name);
}
}
return rolesList.ToArray();
}
Answering this question myself. I finally found out that caching the handle to Azman is what was needed to make it fast even when Azman was file based. I added a property like below to my custom AzmanProvider to accomplish this. And this brought down the role assignment time to 2 seconds!!