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_ ...
随机推荐
- Sobel硬件实现的硬件代码分析(三)
#include "xaxivdma.h" #include "xaxivdma_i.h" #include "xhls_sobel.h" ...
- ORM数据库的增删改查
数据库可视化工具: https://sqlitestudio.pl/index.rvt from app01 import models def orm(request): #增加数据 # 方法1: ...
- 全局解释锁GIL
''' 定义: In CPython, the global interpreter lock, or GIL, is a mutex that prevents multiple native th ...
- 380-Xilinx Kintex UltraScale FPGA KCU1500 Acceleration Development Kit
Xilinx Kintex UltraScale FPGA KCU1500 Acceleration Development Kit Product Description The Kintex® U ...
- Taro -- 微信小程序wxParse达到html转换wxml
Taro微信小程序可以用wxParse来达到html转换wxml的效果:https://github.com/NervJS/taro-components-test/blob/master/src/p ...
- 脚本_使用awk提取linux主机参数
#!bin/bash#功能:使用awk提取Linux主机的参数信息,如内容剩余容量,根分区剩余容量,本机IP,本机能登录的用户个数,CPU负载.#作者:liusingbon#使用awk提取内存剩余容量 ...
- Codeforces Round #426 (Div. 2) - A
题目链接:http://codeforces.com/contest/834/problem/A 题意:给定4个图标,某些图标经过顺时针/逆时针旋转90°后能得到另外一些图标.现在给你开始的图标和结束 ...
- 树——binary-tree-postorder-traversal(树的后序遍历)
问题: Given a binary tree, return the postorder traversal of its nodes' values. For example: Given bin ...
- python3-sorted
排序也是在程序中经常用到的算法.无论使用冒泡排序还是快速排序,排序的核心是比较两个元素的大小.如果是数字,我们可以直接比较,但如果是字符串或者两个dict呢?直接比较数学上的大小是没有意义的,因此,比 ...
- 解决安装mysql-connector-odbc-5.3.2 错误1918……不能加载安装或转换器库……的BUG
还是在虚拟机Windows Server 2003上安装mysql-connector-odbc-5.3.2,装着装着就报错了,大致是“错误1918……不能加载安装或转换器库……”,问我Retry,I ...