从不同的域中枚举Active Directory中的用户组

我有一个.net Web应用程序,需要获取用户是活动目录中成员的组。

我的代码完美地使用我的ID,但是当我在应用程序ID下运行它时,会出现以下错误:

COMException (0x8007052e): Logon failure: unknown user name or bad password. ] System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +420085 System.DirectoryServices.DirectoryEntry.Bind() +36 System.DirectoryServices.DirectoryEntry.get_AdsObject() +31 System.DirectoryServices.PropertyValueCollection.PopulateList() +26 System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) +49 System.DirectoryServices.PropertyCollection.get_Item(String propertyName) +141 System.DirectoryServices.ActiveDirectory.PropertyManager.GetPropertyValue(DirectoryContext context, DirectoryEntry directoryEntry, String propertyName) +57 

我用来运行应用程序的ID与用户不在同一个域中。 我发现这个答案,但我不知道它是否可以适用于跨域ID。

我们需要什么样的configuration才能工作?

谢谢

您正在寻找的是Active Directory委派。 MSFT已经发布了可以使用的最佳实践文档 。 然而它的实现非常简单 。 我也有一个简单的一步一步的代码设置,我写了一个开源的AD应用程序,你可以看看: