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

推荐订阅源

S
Secure Thoughts
S
Securelist
P
Proofpoint News Feed
D
DataBreaches.Net
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Project Zero
Project Zero
A
About on SuperTechFans
罗磊的独立博客
WordPress大学
WordPress大学
月光博客
月光博客
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy International News Feed
AI
AI
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
Help Net Security
Help Net Security
T
Tor Project blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MyScale Blog
MyScale Blog
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
T
Threat Research - Cisco Blogs
B
Blog RSS Feed
博客园 - 叶小钗
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Simon Willison's Weblog
Simon Willison's Weblog
C
CERT Recently Published Vulnerability Notes
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic

博客园 - 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的支持不够充分。