2012-06-28 41 views
0

我的任务是将一些c#v4应用程序从一台服务器迁移到另一台服务器,并且我遇到了其中一个aspx窗体的问题。userprinciple.FindByIdentity在一台服务器上成功,但不是另一台

表单调用一个类来在其代码后面的文件中搜索AD用户。它所调用的方法如下。

public UserPrincipal GetADUser(string samAccountName) 
     { 
     try 
     { 
      UserPrincipal user = UserPrincipal.FindByIdentity(AD.domainContext, samAccountName); 
      return user; 
     } 
     catch(Exception ex) 
     { 
      throw new Exception(" Cant perform this operation:-"+ex.Message); 
     } 
    } 

AD.domainContext定义如下

private static PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, ConfigurationHandler._ADDomain);

我的问题是,该方法适用于我的服务器2(VS开发和服务器正在运行,即时通讯迁移的代码)和在尝试迁移到的服务器上引发异常。所有服务器相​​同的环境中的Windows Server R2 2K8运行IIS 7.5

正被抛出是

广东话执行该操作的错误:出现 - 一个操作错误。

我有一个搜索,发现下面的计算器问题,但没有人可以解决问题

System.DirectoryServices.AccountManagement.PrincipalContext and Impersonation in a WCF service

Active Directory COM Exception - An operations error occurred (0x80072020)

没有人有任何想法什么会导致此错误是抛在一个环境而不是任何其他?

我试图调试代码,它在VS调试中工作正常,但是当代码部署到所述服务器时是我遇到问题时。

任何帮助,想法,想法将不胜感激。

如果我忘记包括任何东西,我很乐意详细说明所提供的任何信息。

在此先感谢

尼古拉斯

回答

1

为别人谁面临着类似的问题的解决方案似乎是用户名和密码需要提供查询AD,除非你有用户impersination在IIS中开启。

只需ammending我的方法有以下解决问题

private static PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, null,ConfigurationHandler._ADDomain, ConfigurationHandler._ADUser, ConfigurationHandler._ADPassword); 

感谢

尼古拉斯

相关问题