Accessing Active Directory using C

喜夏-厌秋 提交于 2019-12-13 04:29:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!