zoukankan      html  css  js  c++  java
  • 域中搜索用户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;
            }
  • 相关阅读:
    lambda表达式
    Shiro身份认证---转
    反转数组
    HashMap去重
    开发工具软件下载地址
    setInterval的使用和停用
    手机端的META
    spring自定义参数绑定(日期格式转换)
    mybatis注解动态sql
    SpringMVC文件上传
  • 原文地址:https://www.cnblogs.com/catvi/p/2001053.html
Copyright © 2011-2022 走看看