ldap_integration
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| ldap_integration [2009/08/18 11:36] – alan | ldap_integration [2024/07/05 09:59] (current) – removed aorth | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== LDAP Integration ===== | ||
| - | ILRI uses an Active Directory server for user authentication, | ||
| - | |||
| - | <note warning> | ||
| - | |||
| - | This was working once, using a // | ||
| - |   * Compile the code:  '' | ||
| - |   * Link the code:  '' | ||
| - | |||
| - | **pam_cgiar_ldap.c**: | ||
| - | <code c> | ||
| - | #define DEFAULT_USER " | ||
| - | |||
| - | #include < | ||
| - | |||
| - | /* | ||
| - | * here, we make definitions for the externally accessible functions | ||
| - | * in this file (these definitions are required for static modules | ||
| - | * but strongly encouraged generally) they are used to instruct the | ||
| - | * modules include file to define their prototypes. | ||
| - | */ | ||
| - | |||
| - | #define PAM_SM_AUTH | ||
| - | #define PAM_SM_ACCOUNT | ||
| - | #define PAM_SM_SESSION | ||
| - | #define PAM_SM_PASSWORD | ||
| - | |||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | |||
| - | int testBind(char* loginDN, char* password) | ||
| - | { | ||
| - |   struct timeval timeOut = {10, | ||
| - |   int returnValue=0; | ||
| - | char* pass2; | ||
| - |   pass2=password; | ||
| - |   char tempPass[100]; | ||
| - | |||
| - |   // | ||
| - |   strcat(loginDN," | ||
| - |   //syslog (LOG_ERR, " | ||
| - | |||
| - | LDAP *ld; | ||
| - |   int version = LDAP_VERSION3; | ||
| - |   ldap_set_option( NULL, LDAP_OPT_PROTOCOL_VERSION, | ||
| - |   ldap_set_option( NULL, LDAP_OPT_NETWORK_TIMEOUT, | ||
| - |   ld = ldap_init(" | ||
| - |   if (ld==NULL) printf(" | ||
| - | int rc; | ||
| - |   //if (ldap_simple_bind_s( ld, loginDN, | ||
| - |   if (ldap_simple_bind_s( ld, loginDN, | ||
| - | |||
| - | |||
| - | { | ||
| - | returnValue =0; | ||
| - |       syslog (LOG_ERR, " | ||
| - |        | ||
| - | } | ||
| - | else | ||
| - | { | ||
| - |     | ||
| - |   syslog (LOG_ERR, " | ||
| - | |||
| - | } | ||
| - | /* | ||
| - | FILE* outFile; | ||
| - |   outFile=fopen ("/ | ||
| - |   fprintf(outFile," | ||
| - | // if (rc==PAM_SUCCESS) | ||
| - |   fprintf(outFile," | ||
| - |   | ||
| - | */ | ||
| - | // return(0); | ||
| - |   return (returnValue); | ||
| - | |||
| - | } | ||
| - | |||
| - | /* --- authentication management functions --- */ | ||
| - | |||
| - | PAM_EXTERN | ||
| - | int pam_sm_authenticate(pam_handle_t *pamh,int flags,int argc,const char **argv) | ||
| - | { | ||
| - | int retval,rc; | ||
| - | const char *user=NULL; | ||
| - | char *p; | ||
| - | //syslog (LOG_ERR, " | ||
| - | |||
| - | /* | ||
| - | * authentication requires we know who the user wants to be | ||
| - | */ | ||
| - |     retval = pam_get_user(pamh, | ||
| - | if (retval != PAM_SUCCESS) { | ||
| - | 	D((" | ||
| - | return retval; | ||
| - | } | ||
| - | |||
| - |    // rc=pam_get_item (pamh, PAM_AUTHTOK, | ||
| - | |||
| - |    | ||
| - |     if (user == NULL || *user == ' | ||
| - | 	D((" | ||
| - | 	retval = pam_set_item(pamh, | ||
| - | if (retval != PAM_SUCCESS) | ||
| - | 	    return PAM_USER_UNKNOWN; | ||
| - | } | ||
| - | // user = NULL; /* clean up */ | ||
| - | |||
| - |    // return PAM_SUCCESS; | ||
| - | |||
| - | //changes introduced by lavila | ||
| - | // I still cannot put this module on top of the stack | ||
| - | // I have to put it at least on second place | ||
| - | // or my password information returns null when using get_itme | ||
| - |  // | ||
| - |   rc=pam_get_item (pamh, PAM_AUTHTOK, | ||
| - | // if (rc == PAM_SUCCESS) | ||
| - | |||
| - | char luser[100]; | ||
| - |     | ||
| - | // if (p!=NULL) | ||
| - | /* { | ||
| - | FILE* outFile; | ||
| - |     outFile=fopen ("/ | ||
| - |     fprintf(outFile," | ||
| - |     fprintf(outFile," | ||
| - |     fclose(outFile); | ||
| - |     rc = testBind(luser, | ||
| - | }*/ | ||
| - | |||
| - | |||
| - |     rc = testBind(luser, | ||
| - | |||
| - | // rc=0; | ||
| - |  if (rc==1)  | ||
| - |   return PAM_SUCCESS; | ||
| - |  else return PAM_AUTH_ERR; | ||
| - | |||
| - | 	   // return PAM_USER_UNKNOWN; | ||
| - |    // | ||
| - | |||
| - | |||
| - | |||
| - | } | ||
| - | |||
| - | PAM_EXTERN | ||
| - | int pam_sm_setcred(pam_handle_t *pamh,int flags,int argc | ||
| - | 		   , | ||
| - | { | ||
| - |       | ||
| - | //	    return PAM_USER_UNKNOWN; | ||
| - | |||
| - | } | ||
| - | |||
| - | /* --- account management functions --- */ | ||
| - | |||
| - | PAM_EXTERN | ||
| - | int pam_sm_acct_mgmt(pam_handle_t *pamh,int flags,int argc | ||
| - | 		     , | ||
| - | { | ||
| - |       | ||
| - | |||
| - | } | ||
| - | |||
| - | /* --- password management --- */ | ||
| - | |||
| - | PAM_EXTERN | ||
| - | int pam_sm_chauthtok(pam_handle_t *pamh,int flags,int argc | ||
| - | 		     , | ||
| - | { | ||
| - |       | ||
| - | |||
| - | |||
| - | } | ||
| - | |||
| - | /* --- session management --- */ | ||
| - | |||
| - | PAM_EXTERN | ||
| - | int pam_sm_open_session(pam_handle_t *pamh,int flags,int argc | ||
| - | ,const char **argv) | ||
| - | { | ||
| - |     return PAM_SUCCESS; | ||
| - | } | ||
| - | |||
| - | PAM_EXTERN | ||
| - | int pam_sm_close_session(pam_handle_t *pamh,int flags,int argc | ||
| - | ,const char **argv) | ||
| - | { | ||
| - |       | ||
| - | } | ||
| - | |||
| - | /* end of module definition */ | ||
| - | |||
| - | #ifdef PAM_STATIC | ||
| - | |||
| - | /* static module data */ | ||
| - | |||
| - | /*struct pam_module_pam_permit_modstruct = { | ||
| - |     " | ||
| - | struct pam_module_pam_cgiar_ldap_modstruct = { | ||
| - |     " | ||
| - |     pam_sm_authenticate, | ||
| - |     pam_sm_setcred, | ||
| - |     pam_sm_acct_mgmt, | ||
| - |     pam_sm_open_session, | ||
| - |     pam_sm_close_session, | ||
| - | pam_sm_chauthtok | ||
| - | }; | ||
| - | |||
| - | #endif | ||
| - | </ | ||
ldap_integration.1250595408.txt.gz · Last modified:  (external edit)
                
                