本地ADFS的LDAP访问
创始人
2024-11-29 02:00:10
0

要在本地ADFS中访问LDAP,您可以使用以下代码示例的解决方法:

using System.DirectoryServices;

// 设置LDAP连接参数
string ldapPath = "LDAP://example.com"; // LDAP服务器的地址
string username = "username"; // LDAP用户名
string password = "password"; // LDAP密码

// 创建LDAP连接
DirectoryEntry ldapConnection = new DirectoryEntry(ldapPath, username, password);

// 搜索AD中的对象
DirectorySearcher ldapSearcher = new DirectorySearcher(ldapConnection);
ldapSearcher.Filter = "(objectClass=user)"; // 这里可以根据需要设置搜索过滤器
ldapSearcher.PropertiesToLoad.Add("cn"); // 这里可以根据需要设置要加载的属性

// 执行搜索操作
SearchResultCollection ldapResults = ldapSearcher.FindAll();

// 处理搜索结果
foreach (SearchResult ldapResult in ldapResults)
{
    if (ldapResult.Properties["cn"].Count > 0)
    {
        string commonName = ldapResult.Properties["cn"][0].ToString();
        Console.WriteLine("Common Name: " + commonName);
    }
}

// 关闭LDAP连接
ldapConnection.Close();

请注意,上述代码示例假设您具有正确的LDAP服务器地址、用户名和密码,并且您可以根据需要自定义搜索过滤器和要加载的属性。另外,确保您的应用程序具有访问LDAP服务器的权限。

相关内容

热门资讯

线上(wepoke真的)原来是... 线上(wepoke真的)原来是真的有挂!其实真的有挂(2022已更新)(哔哩哔哩);亲,其实确实真的...
两教程(Wepoke程序)软件... 两教程(Wepoke程序)软件透明挂辅助工具(软件透明挂)透视辅助(2024已更新)(哔哩哔哩);致...
软件(wepoke透明)原来是... 软件(wepoke透明)原来是真的有挂!其实真的有挂(2020已更新)(哔哩哔哩)是一款可以让一直输...
一模拟器(德扑工具)外挂辅助工... 一模拟器(德扑工具)外挂辅助工具(透视)透视辅助(2025已更新)(哔哩哔哩);亲真的是有正版授权,...
系统(aapoker讲解)竟然... 系统(aapoker讲解)竟然真的有挂!其实真的有挂(2021已更新)(哔哩哔哩);aapoker讲...
6系统(aapoker下载)外... 6系统(aapoker下载)外挂辅助工具(辅助挂)透视辅助(2023已更新)(哔哩哔哩)aapoke...
智能(德扑之星刷数据)果真真的... 智能(德扑之星刷数据)果真真的有挂!原来真的有挂(2025已更新)(哔哩哔哩);《WPK辅助透视》‌...
1机器人(德州nzt软件)软件... 1机器人(德州nzt软件)软件透明挂辅助软件(透视)透视辅助(2022已更新)(哔哩哔哩);人气非常...
ai代打(德扑之星决策)确实是... ai代打(德扑之星决策)确实是真的有挂!原来真的有挂(2020已更新)(哔哩哔哩);科技详细教程小薇...
第8透明(wepoke数据)外... 第8透明(wepoke数据)外挂透明挂辅助神器(辅助挂)透视辅助(2023已更新)(哔哩哔哩);原来...