使用C访问Active Directory

在http://www-archive.mozilla.org/directory/csdk-docs/example.htm的代码中进行了一些修改之后,我尝试了以下代码。

# include  # include "ldap.h" int main( int argc, char **argv ) { LDAP *ld; int rc; /* Get a handle to an LDAP connection. */ if ( (ld = ldap_init( "ipaddr", port )) == NULL ) { perror( "ldap_init" ); return( 1 ); } /* Bind anonymously to the LDAP server. */ rc = ldap_simple_bind_s( ld, "user@mydomain.com", "***" ); if ( rc != LDAP_SUCCESS ) { fprintf(stderr, "ldap_simple_bind_s: %s\n", ldap_err2string(rc)); return( 1 ); } else { printf("Successful authentication"); } } 

我没有ldap.h头文件。 我试图从openldap(v2.4.35)下载一个包并解压缩到一个包含头文件的文件夹。 我在执行期间包含了这个文件夹,发现两个文件缺少lber_types.h和ldap_features.h。 我探索了这个包,找到了lber_types.hin和ldap_features.hin文件。 我还从Internet上找到了一个信息,lber_types和ldap_features头文件是由Linux中的configure命令自动生成的。 我在Windows中工作,现在该怎么办? 有没有其他包来执行代码?

如果您正在寻找除Windows上的openldap之外的其他选项。 您可以尝试winldap,有关更多信息,您可以访问他们的msdn页面,也有一些例子可以帮助您。

http://msdn.microsoft.com/en-us/library/windows/desktop/aa367033(v=vs.85).aspx

    Interesting Posts