Changeset a15c097
- Timestamp:
- 2006-03-24T16:48:16Z (19 years ago)
- Branches:
- master
- Children:
- 9779c18
- Parents:
- d5dfc3d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
storage_ldap.c
rd5dfc3d ra15c097 46 46 47 47 if (!ld) { 48 /* FIXME: report error */48 log_message( LOGLVL_WARNING, "Unable to connect to LDAP server at %s", BB_LDAP_HOST ); 49 49 return STORAGE_OTHER_ERROR; 50 50 } … … 58 58 case LDAP_INVALID_CREDENTIALS: status = STORAGE_INVALID_PASSWORD; break; 59 59 default: 60 /* FIXME: Log */60 log_message( LOGLVL_WARNING, "Unable to authenticate %s: %s", mydn, ldap_err2string(ret) ); 61 61 status = STORAGE_OTHER_ERROR; 62 62 break; … … 68 68 } 69 69 70 static void sldap_init (void)71 {72 }73 74 70 static storage_status_t sldap_load ( const char *my_nick, const char* password, irc_t *irc ) 75 71 { 76 LDAPMessage *res ;72 LDAPMessage *res, *msg; 77 73 LDAP *ld; 78 int ret ;74 int ret, i; 79 75 storage_status_t status; 80 76 char *mydn; … … 86 82 mydn = nick_dn(my_nick); 87 83 88 ret = ldap_search_s(ld, mydn, LDAP_SCOPE_ONELEVEL, "(objectClass=*)", NULL, 0, &res); 84 ret = ldap_search_s(ld, mydn, LDAP_SCOPE_BASE, "(objectClass=*)", NULL, 0, &res); 85 86 if (ret != LDAP_SUCCESS) { 87 log_message( LOGLVL_WARNING, "Unable to search for %s: %s", mydn, ldap_err2string(ret) ); 88 ldap_unbind_s(ld); 89 return STORAGE_OTHER_ERROR; 90 } 89 91 90 92 g_free(mydn); 91 93 92 /* FIXME: Check ret */ 94 for (msg = ldap_first_entry(ld, res); msg; msg = ldap_next_entry(ld, msg)) { 95 } 93 96 94 97 /* FIXME: Store in irc_t */ 95 96 return STORAGE_OK;97 }98 98 99 static storage_status_t sldap_save( irc_t *irc, int overwrite ) 100 { 101 LDAP *ld; 102 char *mydn; 103 storage_status_t status; 104 105 status = nick_connect(irc->nick, irc->password, &ld); 106 if (status != STORAGE_OK) 107 return status; 108 109 mydn = nick_dn(irc->nick); 110 111 /* FIXME */ 112 113 g_free(mydn); 99 ldap_unbind_s(ld); 114 100 115 101 return STORAGE_OK; … … 145 131 146 132 if (ret != LDAP_SUCCESS) { 147 /* FIXME: report */ 133 log_message( LOGLVL_WARNING, "Error removing %s: %s", mydn, ldap_err2string(ret) ); 134 ldap_unbind_s(ld); 148 135 return STORAGE_OTHER_ERROR; 149 136 } 137 138 ldap_unbind_s(ld); 150 139 151 140 g_free(mydn); … … 153 142 } 154 143 144 static storage_status_t sldap_save( irc_t *irc, int overwrite ) 145 { 146 LDAP *ld; 147 char *mydn; 148 storage_status_t status; 149 LDAPMessage *msg; 150 151 status = nick_connect(irc->nick, irc->password, &ld); 152 if (status != STORAGE_OK) 153 return status; 154 155 mydn = nick_dn(irc->nick); 156 157 /* FIXME: Make this a bit more atomic? What if we crash after 158 * removing the old account but before adding the new one ? */ 159 if (overwrite) 160 sldap_remove(irc->nick, irc->password); 161 162 g_free(mydn); 163 164 ldap_unbind_s(ld); 165 166 return STORAGE_OK; 167 } 168 169 170 155 171 storage_t storage_ldap = { 156 172 .name = "ldap", 157 .init = sldap_init,158 173 .check_pass = sldap_check_pass, 159 174 .remove = sldap_remove,
Note: See TracChangeset
for help on using the changeset viewer.