Active Directory 是否支持事务?

发布于 2024-07-30 17:36:20 字数 419 浏览 2 评论 0 原文

简单的问题,但我在任何地方都找不到答案:Active Directory 是否支持事务?

换句话说,以下更改是否会回滚(因为我没有调用scope.Complete()):

using (var scope = new TransactionScope())
{
    DirectoryEntry entry = ...;
    entry.Properties["givenName"].Value = "New Given Name";
    entry.CommitChanges();
}

如果没有,是否可以以某种方式启用此功能? 现在,我有执行数据库更新和相应 AD 更新的代码,并且在 AD 更新因某种原因失败时我有补偿逻辑。 这个解决方案远非最佳。

亲切的问候, 罗纳德·维尔登伯格

Simple question but I can't find the answer anywhere: is Active Directory transaction-aware?

In other words, will the following change be rolled back (since I didn't call scope.Complete()):

using (var scope = new TransactionScope())
{
    DirectoryEntry entry = ...;
    entry.Properties["givenName"].Value = "New Given Name";
    entry.CommitChanges();
}

If not, is it possible to enable this somehow? Right now I have code that performs database updates and corresponding AD updates and I have compensating logic for the AD updates if they somehow fail. This solution is far from optimal.

Kind regards,
Ronald Wildenberg

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

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

发布评论

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

评论(2

故事未完 2024-08-06 17:36:20

简短的回答是——不。 ActiveDirectory 本质上是一个 LDAP 实现(带有一些奇特的扩展,但其核心仍然是 LDAP)。 LDAP 协议和规范都没有事务的概念,因此这实际上是不可能的。

可以在客户端模拟事务,但您必须自己执行此操作或使用 Spring,我相信它会为您执行此操作 - 显然这不如您期望的服务器端事务那么安全一个数据库。 关于 Spring 的注释 - 我还不能完全确定 Spring.NET 支持 LDAP 的“事务”,但在 Spring 的 Java 实现中它们有类似的东西。 也许值得一看。

通过阅读 CommitChanges 方法的文档,它只是说它将您的更改发送到服务器 - 如果它没有指出它们是事务安全的,我会认为它们不是。

一些随机的想法 - 我猜想 Microsoft 可能会在 ActiveDirectory 上添加类似的内容(因为它不仅仅是 LDAP),但如果他们愿意的话,他们可能不会还没有。

Short answer is - no. ActiveDirectory is essentially an LDAP implementation (with some fancy extensions but at it's core it is still LDAP). Neither the LDAP protocols nor the specs have the concept of transactions so this really isn't possible.

It would be possible to emulate transactions on the client side but you'd have to do that yourself or use Spring which, I believe, will do that for you - obviously this is not as safe as server side transactions that you'd expect from a DB. A note on Spring - I'm not completely sure that Spring.NET supports 'transactions' for LDAP yet but they have something like that in the Java implementation of Spring. It might be worth a look.

From reading the docs on the CommitChanges method it just says that it sends your changes to the server - if it doesn't make a point of saying that they are transaction safe I would assume that they're not.

Some random thoughts - I guess it would be possible that Microsoft could add something like this onto ActiveDirectory (as it is more than just LDAP) but they probably won't if they haven't yet.

撕心裂肺的伤痛 2024-08-06 17:36:20

不。LDAP 不直接支持事务,但是,可以通过编写实现 IEnlistmentNotification 接口的登记类来“推出您自己的”解决方案。 IEnlistmentNotification 适用于 System.Transactions 命名空间中的显式和隐式事务。

您可以在此处找到更多文档(和示例):https://msdn.microsoft.com/en-us/library/system.transactions.ienlistmentnotification(v=vs.110).aspx

No. LDAP doesn't directly support transactions, however, it is possible to 'roll your own' solution by writing an enlistment class that implements the IEnlistmentNotification Interface. IEnlistmentNotification works with both explicit and implicit transactions in the System.Transactions namespace.

You can find more documentation (and an example) here: https://msdn.microsoft.com/en-us/library/system.transactions.ienlistmentnotification(v=vs.110).aspx

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