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_ ...
随机推荐
- 7、前端知识点--关于Array.from详解
1.Array.from()方法就是将一个类数组对象 或 可遍历对象 或 可迭代对象 转换成一个真正的数组.浅拷贝的数组实例. 2.那么,什么是类数组对象呢?所谓类数组对象,最基本的要求就是具有len ...
- BCR-ABL融合基因及检测
费城染色体 费城染色体(Philadelphia chromosome, Ph (or Ph') chromosome),或称费城染色体易位(Philadelphia translocation),是 ...
- Java REST Client API
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.3/java-rest-high-supported-apis.htm ...
- readlink 查看符号链接的文件的内容
1. 命令功能 readlink 查看软链接文件里的真实内容. 2. 语法格式 readlink [option] file 参数 参数说明 -f 后跟软链接文件 3. 使用范例 范例1 查看文件链 ...
- 【串线篇】spring boot配置嵌入式servlet容器
SpringBoot默认使用Tomcat作为嵌入式的Servlet容器 问题? 一.如何定制和修改Servlet容器的相关配置 1.方法1修改和server有关的配置(ServerProperties ...
- Spring---MongoDB
1.MongoDB概述 1.1.NoSQL数据库 1.1.1.NoSQL的主要特点: 不使用SQL语言 作为查询条件: 数据存储 也不是固定的表.字段: 1.1.2.NoSQL数据库 主要有 ...
- Linux安装mysql5.6.33
1.下载mysql安装包: 下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads 下载版本:我这里选择的5.6.33,通用版,lin ...
- Graph Neural Networks for Computer Vision
Graph Neural Networks for Computer Vision I was attracted by this image: This is an inspiring image ...
- 英语单词vendors
vendors 来源——https://www.docker.com/products/docker-hub Share and Collaborate with Docker Hub Docker ...
- cenos中的软件安装
在linux中安装flash: http://jingyan.baidu.com/article/fa4125accdeeec28ad709252.html linux java环境的搭建: