善待自己,珍惜今天,恩泽他人,享受生活

不放弃任何解决困难的机会,人的一生就是解决困难的过程。 当我们走完一生才能说没有问题要解决了。 面对工作、生活上的压力,面对来自家庭、朋友、同事、上司等的困惑。 要排除万难,否则我们就会被万难排除!

博客园 首页 新随笔 联系 订阅 管理

       我在使用Net2.0对AD编程取用户信息的时候发生了一个百思不得其解的问题,对以下的代码:
string m_strRoot="LDAP://192.168.24.12/CN=users,DC=vs-mail,DC=com"
m_obDirEntry = new DirectoryEntry(strRoot);
m_obDirEntry = GetDirectoryObject();
SearchResultCollection results;
   DirectorySearcher srch = new DirectorySearcher(m_obDirEntry);
      srch.Filter = "(&(&(objectCategory=person)(objectClass=user))(sAMAccountName="+strLogin+"))";
           //srch.SearchScope = SearchScope.Subtree;
     results = srch.FindAll();

 private static DirectoryEntry GetDirectoryObject()
        {
            DirectoryEntry entry = new DirectoryEntry("LDAP://192.168.24.12/CN=users,DC=vs-mail,DC=com", "administrator", "Admin@1",         AuthenticationTypes.Secure);
            return entry;
        }

当我红色底字的代码而不用绿色底字的代码只能在 file system 的web程序上运行成功,但真正放到生产中的web上就取不出用户数据
但我绿色底字的代码而不用红色底字的代码则在什么环境都行,我不知道到底是怎么回事?有高手能帮助解答一下吗?
                                    
  

posted on 2006-06-28 17:05  笨笨丁  阅读(674)  评论(2编辑  收藏  举报