我正在尝试在Windows Server 2008 R2(已安装IIS7)上运行的ASP.Net(4.0)应用程序中查询AD。在本地计算机(Windows 7)上运行正常,但在服务器上运行不正常。我正在尝试获取当前用户的用户标识。我看过类似问题的Q& A,但没有成功。
这是代码片段......
public partial class Default : System.Web.UI.Page
{
PrincipalContext principalCtx = new PrincipalContext(ContextType.Domain);
UserPrincipal currentUser = UserPrincipal.Current;
web.config有
<authentication mode="Windows"/>
<identity impersonate="true" />
这是错误&amp;堆栈跟踪...
[DirectoryServicesCOMException (0x80072020): An operations error occurred.
]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +781
System.DirectoryServices.DirectoryEntry.Bind() +44
System.DirectoryServices.DirectoryEntry.get_AdsObject() +42
System.DirectoryServices.PropertyValueCollection.PopulateList() +29
System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) +119
System.DirectoryServices.PropertyCollection.get_Item(String propertyName) +163
System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInitNoContainer() +541617
System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit() +51
System.DirectoryServices.AccountManagement.PrincipalContext.Initialize() +141
System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx() +42
System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate) +27
System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, IdentityType identityType, String identityValue) +146
System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue) +44
System.DirectoryServices.AccountManagement.UserPrincipal.get_Current() +390
我尝试将IIS应用程序池作为NetworkService和ApplicationPoolIdentity运行,并且没有用。
有什么想法吗?感谢。