csharp - retrieve LDAP
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的更多相关文章
- net-ldap for ruby openNebula ldap
preface:ldap 主要概念及术语 OpenNebula issues:missing step to use LDAP as default driver cp -r /var/lib/one ...
- ldap理论属于概念缩略词
Standalone LDAP Daemon, slapd(standalone lightweight access protocol) ldap 389 default listener port ...
- 单点登录之CAS SSO从入门到精通(第三天)
开场白 各位新年好,上海的新年好冷,冷到我手发抖. 做好准备全身心投入到新的学习和工作中去了吗?因为今天开始的教程很"变态"啊,我们要完成下面几件事: 自定义CAS SSO登录界面 ...
- 在Windows和UNIX下利用PHP和LDAP进行身份验证
我现在的老板曾要求我为企业内部的Web服务提供一种标准的身份验证方法.我遇到的一个主要问题就是我们公司主要使用了两种平台:UNIX和.所以,我的第一个想法并不很成功:它要求每个员工都使用UNIX或者L ...
- Active Directory: LDAP Syntax Filters
LDAP syntax filters can be used in many situations to query Active Directory. They can be used in VB ...
- Mantis集成 LDAP 认证
mantis的用户认证函数Authentication中相关有 $g_login_method MD5 LDAP PLAIN CRYPT CRYPT_FULL_SALT BASIC_AUTH Some ...
- Centos 7 vsftpd ldap 配置
#ldap 安裝配置 环境Centos7#安装 yum install -y openldap openldap-clients openldap-servers migrationtools pam ...
- ABP源码分析四十六:ABP ZERO中的Ldap模块
通过AD作为用户认证的数据源.整个管理用户认证逻辑就在LdapAuthenticationSource类中实现. LdapSettingProvider:定义LDAP的setting和提供Defaut ...
- c#操作MangoDB 之MangoDB CSharp Driver驱动详解
序言 MangoDB CSharp Driver是c#操作mongodb的官方驱动. 官方Api文档:http://api.mongodb.org/csharp/2.2/html/R_Project_ ...
随机推荐
- wikioi 2144 分步二进制枚举+map记录
题目描写叙述 Description 有n个砝码,如今要称一个质量为m的物体,请问最少须要挑出几个砝码来称? 注意一个砝码最多仅仅能挑一次 输入描写叙述 Input Description 第一行两个 ...
- GitHub上更新原有的项目代码(二)
转载自:https://blog.csdn.net/dayewandou/article/details/79175783 项目上传了,现在又写了一些内容想要跟新到项目上去,怎么更新呢? 首先进入项目 ...
- org.hibernate.hql.ast.QuerySyntaxException: tb_voteoption is not mapped [from tb_voteoption where voteID=?]
转自:https://www.cnblogs.com/albert1017/archive/2012/08/25/2656873.html org.hibernate.hql.ast.QuerySyn ...
- mv 移动或重命名文件
1. 命令功能 mv:移动或改文件名 2. 语法格式 mv [option] source dest mv 选项 源文件 目标文件 参数 参数说明 -f 如果目标文件存在,则不会询问而是直接覆 ...
- 解决pycharm运行py文件时只有unittest选项的方法
有时候在编完脚本开始运行时,发现某个py脚本右键运行的选项不是run,二是run in unittest,试过很多方法都不能很好的去除,主要是因为脚本中含有test字符串,一种解决方法是将脚本中所有的 ...
- [POI2008]BLO(Tarjan)
[POI2008]BLO Description Byteotia城市有\(n\)个 towns \(m\)条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 所 ...
- nginx http正向代理简单配置及systemd 配置
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #erro ...
- 安装kafka多节点
安装多节点的kafka只需要创建多份配置文件(server.properties),然后指定他们启动kafka服务即可,本例中采用一台服务器来模拟3个节点的kafka集群搭建.同理,使用一台服务器搭建 ...
- JS原型和原型链(3)
构造函数创建对象: function Person() { } var person = new Person(); person.name = 'Kevin'; console.log(person ...
- JUC并发工具类
原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11449367.html java.util.concurrent及其子包,集中了Java并发的各种基础 ...