novell.directory.ldap获取邮箱活动目录
在windows系统上可以使用下列方法来查找所有的员工邮箱和员工组:
StringDictionary ReturnArray = new StringDictionary();
Dictionary<string, string> resultDict = new Dictionary<string, string>();
DirectoryEntry deDirEntry = new DirectoryEntry("LDAP://mail.test.com",
UserName,
Password,
AuthenticationTypes.Secure); DirectorySearcher mySearcher = new DirectorySearcher(deDirEntry); string sFilter = String.Format("(&(mailnickname=*)(|(objectcategory=user)(objectcategory=group)))");//(objectcategory=user)(objectcategory=group) mySearcher.Filter = sFilter;
mySearcher.Sort.Direction = System.DirectoryServices.SortDirection.Ascending;
mySearcher.Sort.PropertyName = "cn";
mySearcher.PageSize = ; SearchResultCollection results;
results = mySearcher.FindAll();
但是在移动端使用xamarin开发的时候是不能用上面的类的,需要使用其他的类库。
下面推荐使用novell.directory.ldap类库,可以在NuGet上搜索LDAP即可查到,在我们安装程序包时可能遇到在PCL(可移植的)上无法安装,没关系,我们可以单独只装各平台的代码就可以了,虽然写的代码一样,但是就是要分平台来写,下面是例子:
cn.Connect("mail.test.com", );
cn.Bind("test@test.com", "**password**");
string sFilter = String.Format("(&(mailnickname=*)(|(objectcategory=user)(objectcategory=group)))");
LdapSearchResults ldapSearchResults = cn.Search("CN=Users,DC=corp,DC=test,DC=com", LdapConnection.SCOPE_SUB, sFilter, null, false);
var entries = new List<LdapEntry>();
try
{
while (ldapSearchResults.hasMore())
{
entries.Add(ldapSearchResults.next());
}
}
catch (LdapException ex)
{
System.Console.WriteLine(ex.LdapErrorMessage);
}
注意事项,使用novell.directory.ldap时,有部分帐号无法连接。Search的参数请根据实际情况配置。
novell.directory.ldap获取邮箱活动目录的更多相关文章
- 使用Novell.Directory.Ldap.NETStandard在.NET Core中验证AD域账号
Novell.Directory.Ldap.NETStandard是一个在.NET Core中,既支持Windows平台,又支持Linux平台,进行Windows AD域操作的Nuget包. 首先我们 ...
- Delphi访问活动目录(使用COM,活动目录Active Directory是用于Windows Server的目录服务)
活动目录Active Directory是用于Windows Server的目录服务,它存储着网络上各种对象的有关信息,并使该信息易于管理员和用户查找及使用.Active Directory使用结构化 ...
- 利用WINDOWS活动目录提供LDAP的方案
Windows Server 2008 R2 活动目录服务安装 http://blog.sina.com.cn/s/blog_622de9390100kgv3.html WINDOWS 2008 域控 ...
- Server2012R2实现活动目录(Active Directory)双域控制器互为冗余
在活动目录中部署两台主控域控制器,两台域控制器互为冗余. Server 2012 R2新建活动目录和DC refer to: https://www.cnblogs.com/jfzhu/p/40061 ...
- Delphi访问活动目录
活动目录Active Directory是用于Windows Server的目录服务,它存储着网络上各种对象的有关信息,并使该信息易于管理员和用户查找及使用.Active Directory使用结构化 ...
- 获取当前进程目录 GetCurrentDirectory() 及 获取当前运行模块路径名GetModuleFileName()
GetCurrentDirectory 获得的是当前进程的活动目录(资源管理器决定的),可以用SetCurrentDirectory 修改的. 转自 http://m.blog.csdn.net/bl ...
- CAS连接微软活动目录的配置方法
原文地址:http://blog.csdn.net/baozhengw/article/details/3857669在微软活动目录中建立一个用户节点,帐号为wangzhenyu,cn为zhenyu ...
- Active Directory中获取域管理员权限的攻击方法
Active Directory中获取域管理员权限的攻击方法 译:by backlion 0x00 前言 攻击者可以通过多种方式在Active Directory中获得域管理员权限, ...
- 利用Azure虚拟机安装Dynamics 365 Customer Engagement之三:安装Windows活动目录域服务
我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...
随机推荐
- CTF 两道web整数溢出题目(猫咪银行和ltshop)
①猫咪银行: (2018中科大hackgame) 一开始给十个CTB,而flag需要20个CTB,我们需要理财赚够20个. 理财是只能买入TDSU才可以获得收益.我们先上来直接把CTB全部换成TDSU ...
- thinkphp3.2.3多图上传并且生成多张缩略图
html部分 <!DOCTYPE html><html><head><meta http-equiv="Content-Type" con ...
- python 模块初识
python的强大之处在于有丰富的实现各种功能的标准库和第三方库,另外还允许用户自己建立库文件, 标准模块(又称为库)包括sys, os, glob, socket, threading, _thre ...
- [转] linux中 参数命令 -- 和 - 的区别
在 Linux 的 shell 中,我们把 - 和 -- 加上一个字符(字符串)叫做命令行参数. 主流的有下面几种风格Unix 风格参数 前面加单破折线 -BSD 风格参数 前面不加破折线GNU 风格 ...
- 微信小程序--问题汇总及详解之tab切换
设置背景颜色就直接在page里设置 page {background-color: rgb(242, 242, 242);} tab切换: navigator 页面链接 传参的格式为url=&q ...
- struts ValueStack 详解
一.ValueStack 1.ValueStack是一个接口,在struts2中使用OGNL(Object-Graph Navigation Language)表达式实际上是使用 ...
- 关于在smarty中实现省市区三级联动
刚开始接触php,,其实对于一些比较深入的东西还不是很了解,就像是这次的省市区联动,都是用三张表为基础编码的,原谅我的无知,谢谢. 接下来就是编码部分了: <?php require('./sm ...
- Codeforces 1158C Permutation recovery
https://codeforces.com/contest/1158/problem/C 题目 已知 $p_1, p_2, \dots, p_n$ 是 $1$ 到 $n$ 的一个排列. 给出关于这个 ...
- BZOJ3260 跳 【组合数】
题目 邪教喜欢在各种各样空间内跳.现在,邪教来到了一个二维平面. 在这个平面内,如果邪教当前跳到了(x,y),那么他下一步可以选择跳到以下4个点: (x-1,y),(x+1,y),(x,y-1),(x ...
- bzoj 2387: [Ceoi2011]Traffic
bzoj 2387: [Ceoi2011]Traffic 题目描述 The center of Gdynia is located on an island in the middle of the ...