问题
I tried the following code after a few modifications in the code from http://www-archive.mozilla.org/directory/csdk-docs/example.htm.
# include <stdio.h>
# 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");
}
}
I dont have the ldap.h header file. I tried to download a package from openldap (v2.4.35) and unzipped to a folder which contained headers. I included this folder during execution and found two files missing lber_types.h and ldap_features.h. I explored the package and found lber_types.hin and ldap_features.hin files. I also found an information from the Internet that lber_types and ldap_features header files are automatically generated by configure command in Linux. I am working in Windows and what should I do now ? Is there any other package to execute the code ?
回答1:
If you are looking for other option other than openldap on Windows. You can try winldap, for more info you can visit their msdn page, there are some examples too which can help you.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa367033(v=vs.85).aspx
来源:https://stackoverflow.com/questions/16956355/accessing-active-directory-using-c