DirectoryEntry de = new DirectoryEntry("LDAP://10.10.10.10:389");
DirectorySearcher searcher = new DirectorySearcher(de, string.Format("(&(objectClass=user)(samAccountName={0}))", "A00106"));
SearchResultCollection src = searcher.FindAll();
foreach (SearchResult rs in src)
{
if (rs != null)
{
string n = (rs.GetDirectoryEntry().Properties["distinguishedName"].Value == null) ? string.Empty : rs.GetDirectoryEntry().Properties["distinguishedName"].Value.ToString();
if (n.IndexOf("OU") != -)
{
//displayName,sAMAccountName,name,mail
string email = (rs.GetDirectoryEntry().Properties["mail"].Value == null) ? string.Empty : rs.GetDirectoryEntry().Properties["mail"].Value.ToString();
}
}
}
// verify user / password

private string GetEmployeeIDByLDAP(string userName, string password)
{ // TODO: Extract
DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://66.66.66.66:389")
{
Username = userName,
Password = password,
AuthenticationType = AuthenticationTypes.Secure
};
try
{
DirectorySearcher searcher = new DirectorySearcher(directoryEntry)
{
Filter = string.Format("(&(objectClass=user)(samAccountName={0}))", userName)
};
SearchResult result = searcher.FindOne();
if (result != null)
{
string empid = result.Properties["name"][].ToString();
return empid;
}
}
catch (Exception err)
{
_logger.Error(err);
} return string.Empty;
}

csharp - retrieve LDAP的更多相关文章

  1. net-ldap for ruby openNebula ldap

    preface:ldap 主要概念及术语 OpenNebula issues:missing step to use LDAP as default driver cp -r /var/lib/one ...

  2. ldap理论属于概念缩略词

    Standalone LDAP Daemon, slapd(standalone lightweight access protocol) ldap 389 default listener port ...

  3. 单点登录之CAS SSO从入门到精通(第三天)

    开场白 各位新年好,上海的新年好冷,冷到我手发抖. 做好准备全身心投入到新的学习和工作中去了吗?因为今天开始的教程很"变态"啊,我们要完成下面几件事: 自定义CAS SSO登录界面 ...

  4. 在Windows和UNIX下利用PHP和LDAP进行身份验证

    我现在的老板曾要求我为企业内部的Web服务提供一种标准的身份验证方法.我遇到的一个主要问题就是我们公司主要使用了两种平台:UNIX和.所以,我的第一个想法并不很成功:它要求每个员工都使用UNIX或者L ...

  5. Active Directory: LDAP Syntax Filters

    LDAP syntax filters can be used in many situations to query Active Directory. They can be used in VB ...

  6. Mantis集成 LDAP 认证

    mantis的用户认证函数Authentication中相关有 $g_login_method MD5 LDAP PLAIN CRYPT CRYPT_FULL_SALT BASIC_AUTH Some ...

  7. Centos 7 vsftpd ldap 配置

    #ldap 安裝配置 环境Centos7#安装 yum install -y openldap openldap-clients openldap-servers migrationtools pam ...

  8. ABP源码分析四十六:ABP ZERO中的Ldap模块

    通过AD作为用户认证的数据源.整个管理用户认证逻辑就在LdapAuthenticationSource类中实现. LdapSettingProvider:定义LDAP的setting和提供Defaut ...

  9. c#操作MangoDB 之MangoDB CSharp Driver驱动详解

    序言 MangoDB CSharp Driver是c#操作mongodb的官方驱动. 官方Api文档:http://api.mongodb.org/csharp/2.2/html/R_Project_ ...

随机推荐

  1. netcore中使用session

  2. 2018-2-13-win10-uwp-读写csv-

    title author date CreateTime categories win10 uwp 读写csv lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17 ...

  3. 机器学习-K-means聚类及算法实现(基于R语言)

    K-means聚类 将n个观测点,按一定标准(数据点的相似度),划归到k个聚类(用户划分.产品类别划分等)中. 重要概念:质心 K-means聚类要求的变量是数值变量,方便计算距离. 算法实现 R语言 ...

  4. Spring Boot 全局排除 spring-boot-starter-logging 依赖

    https://blog.csdn.net/u013314786/article/details/90412733 项目里使用了log4j2做日志处理,要排除掉Spring Boot 很多jar里边默 ...

  5. 基于Xilinx Kintex-7 FPGA K7 XC7K325T PCIeX8 四路光纤卡

    基于Xilinx Kintex-7 FPGA K7 XC7K325T PCIeX8 四路光纤卡 1. 板卡概述   板卡主芯片采用Xilinx公司的XC7K325T-2FFG900 FPGA,pin_ ...

  6. Nginx优化_压缩处理与内存缓存

    对页面进行压缩处理; 服务器内存缓存. 1.对页面进行压缩处理 [root@proxy ~]# cat /usr/local/nginx/conf/nginx.conf http { ... gzip ...

  7. 覆盖(Override)和重写(Overload)的区别

    Overload Overload是重载的意思. 重载Overload表示同一个类中可以有多个名称相同的方法,但这些方法的参数列表各不相同(即参数个数或类型不同). Overload对我们来说可能比较 ...

  8. windows 使用 git 客户端

    git客户端下载地址:https://www.git-scm.com/ tortoisegit下载地址:https://tortoisegit.org/ 双击下载的安装包,默认安装直到完成. 打开gi ...

  9. Jenkines邮件中添加图片

    1.在Jenkins的邮件插件 Email-ext中的Default Content内容编写html文件,简单模板如下: <html>  <head>  </head&g ...

  10. Python_008(文件操作)

    一.文件操作 1.只读操作 f = open("taibai.txt",mode = "r",encoding = "utf-8" s = ...