循环 IAzApplication IzRoles 集合太慢

发布于 2024-12-19 04:56:30 字数 882 浏览 1 评论 0原文

我有这个简单的代码,它循环遍历 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紅太極 2024-12-26 04:56:30

我自己来回答这个问题。我最终发现,即使 Azman 是基于文件的,也需要缓存 Azman 的句柄才能使其更快。我向自定义 AzmanProvider 添加了如下所示的属性来完成此操作。这将角色分配时间缩短至 2 秒!

    public AzAuthorizationStoreClass AZManStore
    {
        get
        {
            if (_azManStore == null)
            {                    
                _azManStore = new AzAuthorizationStoreClass();
                _azManStore.Initialize(0, this.ConnectionStringName, null);
            }
            return _azManStore;
        }
    }

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!!

    public AzAuthorizationStoreClass AZManStore
    {
        get
        {
            if (_azManStore == null)
            {                    
                _azManStore = new AzAuthorizationStoreClass();
                _azManStore.Initialize(0, this.ConnectionStringName, null);
            }
            return _azManStore;
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文