在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获取邮箱活动目录的更多相关文章

  1. 使用Novell.Directory.Ldap.NETStandard在.NET Core中验证AD域账号

    Novell.Directory.Ldap.NETStandard是一个在.NET Core中,既支持Windows平台,又支持Linux平台,进行Windows AD域操作的Nuget包. 首先我们 ...

  2. Delphi访问活动目录(使用COM,活动目录Active Directory是用于Windows Server的目录服务)

    活动目录Active Directory是用于Windows Server的目录服务,它存储着网络上各种对象的有关信息,并使该信息易于管理员和用户查找及使用.Active Directory使用结构化 ...

  3. 利用WINDOWS活动目录提供LDAP的方案

    Windows Server 2008 R2 活动目录服务安装 http://blog.sina.com.cn/s/blog_622de9390100kgv3.html WINDOWS 2008 域控 ...

  4. Server2012R2实现活动目录(Active Directory)双域控制器互为冗余

    在活动目录中部署两台主控域控制器,两台域控制器互为冗余. Server 2012 R2新建活动目录和DC refer to: https://www.cnblogs.com/jfzhu/p/40061 ...

  5. Delphi访问活动目录

    活动目录Active Directory是用于Windows Server的目录服务,它存储着网络上各种对象的有关信息,并使该信息易于管理员和用户查找及使用.Active Directory使用结构化 ...

  6. 获取当前进程目录 GetCurrentDirectory() 及 获取当前运行模块路径名GetModuleFileName()

    GetCurrentDirectory 获得的是当前进程的活动目录(资源管理器决定的),可以用SetCurrentDirectory 修改的. 转自 http://m.blog.csdn.net/bl ...

  7. CAS连接微软活动目录的配置方法

    原文地址:http://blog.csdn.net/baozhengw/article/details/3857669在微软活动目录中建立一个用户节点,帐号为wangzhenyu,cn为zhenyu ...

  8. Active Directory中获取域管理员权限的攻击方法

    Active Directory中获取域管理员权限的攻击方法         译:by  backlion 0x00 前言 攻击者可以通过多种方式在Active Directory中获得域管理员权限, ...

  9. 利用Azure虚拟机安装Dynamics 365 Customer Engagement之三:安装Windows活动目录域服务

    我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...

随机推荐

  1. 【Jump Game II 】cpp

    题目: Given an array of non-negative integers, you are initially positioned at the first index of the ...

  2. easyui datagrid 学习 (一)

    注意:当使用谷歌浏览器时!需要 设置style="overflow:hidden",这样则可以去掉滚动条!(该样式添加到layout上!) fit:属性 自动填父容器, borde ...

  3. easyui在datagrid只想选择一条

    <table class="" id="jgrid" data-options="fitColumns:true,rownumbers: tru ...

  4. ReentrantLock学习笔记

    参考:https://www.jianshu.com/p/4358b1466ec9 前言: 先来想象一个场景:手把手的进行锁获取和释放,先获得锁A,然后再获取锁B,当获取锁B后释放锁A同时获取锁C,当 ...

  5. Vue2.0 - 生命周期

    <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8 ...

  6. BZOJ 4561 [JLoi2016]圆的异或并 ——扫描线

    扫描线的应用. 扫描线就是用数据结构维护一个相对的顺序不变,带修改的东西. 通常只用于一次询问的情况. 抽象的看做一条垂直于x轴直线从左向右扫过去. 这道题目要求求出所有圆的异或并. 所以我们可以求出 ...

  7. 用session设置访问权限

    在web.xml中 <session-config> <session-timeout>15</session-timeout> </session-conf ...

  8. Java面试题之Integer.valueOf(String s);采用了什么设计模式

    Integer.valueOf(String s);//采用了亨元设计模式: 亨元模式: 它是以一种“节约内存,提高性能”为出发点的设计模式,运用共享技术有效的支持大量细粒度对象的复用. 源码解析: ...

  9. cf 341D lahub and xors

    题目大意 给定初始值为\(0\)的\(n*n\)矩阵 两种操作 矩形内异或一个值 求矩阵内异或和 \(n\le 1000\) 分析 二维线段树标记不下传貌似直接可做 有没有更简便的方法? 考虑异或的特 ...

  10. Javascript&Html-系统对话框

    Javascript&Html-系统对话框 浏览器通常内置三种对话框,他们分别是 alert(),confirm()以及prompt() .这三种对话框的外形跟页面的HTML以及CSS均没有任 ...