我的网站的登录验证需要对接公司的AD域,我写控制台测试对接的时候参考了网上的一系列C#相关文档
public bool ADLogin(string userName, string password) 
    { 
      // sample : 
      // LDAP://xxx.com 
      string domain = System.Configuration.ConfigurationManager.AppSettings["AD_Domain"]; 
        
      try
      { 
        DirectoryEntry entry = new DirectoryEntry(domain, userName, password); 
        object obj = entry.NativeObject; 
        DirectorySearcher search = new DirectorySearcher(entry); 
        search.Filter = string.Format("(SAMAccountName={0})", userName); 
        search.PropertiesToLoad.Add("cn"); 
  
  
        SearchResult result = search.FindOne(); 
        if (result == null) 
          return false; 
      } 
      catch (Exception ex) 
      { 
        log.Error(ex); 
        return false; 
      } 
  
  
      return true; 
    } 但是关于这个验证模式,我很质疑,因为我在本地debug的时候,登录DirectoryEntry(domain, userName, password)用的如果是别人的域账号就直接报错了,用自己的没问题,那么如果我把他部署在服务器上面,会不会也有同样的错误