循环 IAzApplication IzRoles 集合太慢
我有这个简单的代码,它循环遍历 Azman 中的所有应用程序及其所有角色。当我没有为角色分配用户时,它非常有用。但是当我分配用户时(其中 2 个角色有大约 7000 个用户),应用程序会挂在 foreach(IAzRole in _azApp.Roles) 代码中...基本上,当您访问 Roles 集合时,它就会挂起,大约需要 40 分钟出来了。这是完全不能接受的。谁能指出我的解决方案吗?我想要的只是角色分配名称列表,为什么角色分配会减慢速度......?
PS:我的所有用户都在 ADAM 中,Azman 商店也在 ADAM 中。 我也尝试过循环 IAzTasks (roledefinition=1),但这也很慢。
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();
}
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();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己来回答这个问题。我最终发现,即使 Azman 是基于文件的,也需要缓存 Azman 的句柄才能使其更快。我向自定义 AzmanProvider 添加了如下所示的属性来完成此操作。这将角色分配时间缩短至 2 秒!
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!!