惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - zhumao-2

perl将json转换成xml cnblogs终于把以前内容的管理权还给我了~ 曙光服务器千兆光纤网卡安装 关于DBI->connect ($dsn, $db_user, $db_pass, { RaiseError =>1, PrintError => 0}) - zhumao-2 RichCopy 3.5 过期?自己想办法~ 将linux密码存储到OpenLDAP里面=OpenLDAP Everywhere Revisited Perl操作OpenLDAP(未测试) 心得共享:Oracle经验技巧集锦 [From CU] 使用Perl生成usmarc记录 牛郎织女 Perl中的trim函数 在 Perl 中使用内联 perl中的特殊内置变量(转) 从网页中提取链接(转载) 在指定文件夹中的文件中查找包含指定字符的行(这个小东西不错[Perl]) 打开.bz2文件 Windows 能干而 Linux 干不了的事情,那就是不需要干的事情 Linux下用Perl产生新的EXCEL文档 RPM包强制删除
C语言操作OpenLDAP
zhumao-2 · 2005-08-13 · via 博客园 - zhumao-2

包括openldap,netscape(sun),mozilla, novell,ibm等,都提供了LDAP的C SDK和接口函数。作为RFC标准的LDAP结构,struct LDAP是定义为对用户隐藏的,并在各个实现函数中各自定义,以便适应不同的LDAP访问。

#typedef struct ldap LDAP在ldap.h中定义;在2.0版以后,struct LDAP改为隐藏,只能能过函数ldap_set_option 和ldap_get_option访问。(draft-ldapext-ldap-c-api-xx.txt)

使用时:

如:

LDAP *Ld=null;  //声明并初始化LDAP类型的变量指针 *ld;

Ld       =ldap_init( ldaphost, ldapport );  //获取LDAP的会话;

获得会话后,调用ldap_simple_bind_s获得访问LDAP的权限,然后就可以调用不同的函数,如

ldap_search_ext( ld, base, scope, filter, attrs, attrsonly,

             sctrls, cctrls, timeout, sizelimit, &msgid );

即可完成相关的操作。

即步骤为:1。获得会话;2。绑定对象;3。执行操作。

连接例子:

#include <stdio.h>

#include "ldap.h"

/* Adjust these setting for your own LDAP server */

#define HOSTNAME "localhost"

#define PORT_NUMBERLDAP_PORT

#define FIND_DN "uid=bjensen, ou=People, o=Airius.com"

int

main( int argc, char **argv )

{

LDAP*ld;

LDAPMessage*result, *e;

BerElement*ber;

char*a;

char**vals;

int i, rc;

/* Get a handle to an LDAP connection. */

if ( (ld = ldap_init( HOSTNAME, PORT_NUMBER )) == NULL ) {

perror( "ldap_init" );

return( 1 );

}

/* Bind anonymously to the LDAP server. */

rc = ldap_simple_bind_s( ld, NULL, NULL );

if ( rc != LDAP_SUCCESS ) {

fprintf(stderr, "ldap_simple_bind_s: %s\n", ldap_err2string(rc));

return( 1 );

}

/* Search for the entry. */

if ( ( rc = ldap_search_ext_s( ld, FIND_DN, LDAP_SCOPE_BASE,

"(objectclass=*)", NULL, 0, NULL, NULL, LDAP_NO_LIMIT,

LDAP_NO_LIMIT, &result ) ) != LDAP_SUCCESS ) {

fprintf(stderr, "ldap_search_ext_s: %s\n", ldap_err2string(rc));

return( 1 );

}

/* Since we are doing a base search, there should be only

one matching entry. */

e = ldap_first_entry( ld, result );

if ( e != NULL ) {

printf( "\nFound %s:\n\n", FIND_DN );

/* Iterate through each attribute in the entry. */

for ( a = ldap_first_attribute( ld, e, &ber );

a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {

/* For each attribute, print the attribute name and values. */

if ((vals = ldap_get_values( ld, e, a)) != NULL ) {

for ( i = 0; vals[i] != NULL; i++ ) {

printf( "%s: %s\n", a, vals[i] );

}

ldap_value_free( vals );

}

ldap_memfree( a );

}

if ( ber != NULL ) {

ber_free( ber, 0 );

}

}

ldap_msgfree( result );

ldap_unbind( ld );

return( 0 );

}

         i.     Novell函数库:

Novel提供了基于普通LDAP函数库的扩展,主要包括两个部分:针对Novel eDirectory服务器产品的扩展,其次是对如ldapsearch等常用函数的扩展。详情可从:http://developer.novell.com/ndk/qstart/opensource.htm#ldapc  获得帮助;

          ii.     Netscape函数库;

Netscape一度是企业级目录服务提供者,许多LDAP的C例子,实际上都是基于Netscape服务器的。但在Netscape被收购后,其目录服务成了iPlanet和SUN eDirectory产品的一部分,出于支持JAVA和iplanet产品的缘故,SUN对该产品和相关库的支持远不够积极,特别是对linux的支持不够充分,估计也与保护solaris产品有关。

        iii. Mozilla函数库:

Mozilla可以看作是Netscape的另一个分支。准确地说,Netscape本来就是源于Mozilla。Mozilla是也是一个开源的项目,提供完整的C-SDK,缺点是对linux的支持不够充分。