catvi

域中搜索用户email

    static public string GetEmailByUserID(string user_id, string pwd, string neededUser_ID)
        {
            string email = "";
            DirectoryEntry entry = new DirectoryEntry("LDAP://zone1.scb.net", user_id, pwd);
            DirectorySearcher searcher = new DirectorySearcher(entry);
            searcher.Filter = "(SAMAccountName=" + neededUser_ID + ")";
            searcher.PropertiesToLoad.Add("SAMAccountName");
            searcher.PropertiesToLoad.Add("mail");
            SearchResult result = searcher.FindOne();
            if (result != null)
            {
                if (result.Properties.Contains("mail"))
                {
                    email = (string)result.Properties["mail"][0];
                }
            }
            if (entry != null)
            {
                entry.Dispose();
            }
            return email;
        }

分类:

技术点:

相关文章:

  • 2021-06-03
  • 2021-09-28
  • 2018-12-16
  • 2021-10-20
  • 2021-10-22
  • 2021-08-30
  • 2022-12-23
  • 2022-01-13
猜你喜欢
  • 2021-12-02
  • 2022-12-23
  • 2021-08-16
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案