通过 AZROLESLib 刷新 AzMan

发布于 2024-10-18 12:39:15 字数 804 浏览 0 评论 0原文

我们在 .NET 中编写了一个简单的 AzMan 包装类,它使用 AZROLESLib COM 互操作库来访问 AzMan。

一切正常,除了当我们对底层 XML 存储进行更改时,这些更改不会反映在对 AZROLESLib 的后续调用中。

我们的代码看起来像这样:

在类级别,我们存储对授权存储的引用:

IAzAuthorizationStore AuthorisationStore = new AzAuthorizationStoreClass();

在类的构造期间,我们初始化存储:

AuthorisationStore.Initialize(0, XML_STORE_PATH)

每当我们请求角色时,都会执行以下代码:

AuthorisationStore.UpdateCache();
var application = AuthorisationStore.OpenApplication(APPNAME);
// we do a query here and return the results

但是,对 UpdateCache 的调用似乎什么都不做。我尝试在每次调用后使用 CloseApplication,但它只是抛出一个异常:“不支持该请求。(来自 HRESULT 的异常:0x80070032)”。如果我在每次调用时都新建一个 AuthorizationStore,则会收到“拒绝访问”异常(我假设是因为旧的授权存储仍然具有该文件的句柄?)。

如何让授权存储在每次调用时自行刷新?

谢谢!

We've written a simple AzMan wrapper class in .NET which uses the AZROLESLib COM interop library to access AzMan.

It all works fine, except when we make changes to the underlying XML store, those changes do not get reflected in subsequent calls to the AZROLESLib.

Our code looks something like this:

At the class level we store a reference to the authorisation store:

IAzAuthorizationStore AuthorisationStore = new AzAuthorizationStoreClass();

During construction of our class we initialise the store:

AuthorisationStore.Initialize(0, XML_STORE_PATH)

The follow code gets executed whenever we make a request for roles:

AuthorisationStore.UpdateCache();
var application = AuthorisationStore.OpenApplication(APPNAME);
// we do a query here and return the results

However, the call to UpdateCache seems to do nothing at all. I've tried using CloseApplication after every call but it simply throws an exception: "The request is not supported. (Exception from HRESULT: 0x80070032)". If I new up an AuthorisationStore on every call, I get an Access Denied exception instead (I assume because the old Authorisation Store still has a handle to the file?).

How can I get the authorisation store to refresh itself on every call?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

墨小沫ゞ 2024-10-25 12:39:15

我正在关闭它,因为我注意到它现在正在神秘地工作;呼叫

AuthorisationStore.UpdateCache();

是关键之一。我不知道为什么它之前不起作用,但这一定是我做错了什么......

I'm closing this as I've noticed that this is now mysteriously working; the call to

AuthorisationStore.UpdateCache();

is the key one. I have no idea why it wasn't working before, but it must have been something that I was doing wrong...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文