Changeset 620 for trunk/server/source3/lib/smbldap.c
- Timestamp:
- Aug 6, 2011, 6:50:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/lib/smbldap.c
r414 r620 1094 1094 connect to the ldap server under system privilege. 1095 1095 ******************************************************************/ 1096 static int smbldap_connect_system(struct smbldap_state *ldap_state, LDAP * ldap_struct) 1097 { 1096 static int smbldap_connect_system(struct smbldap_state *ldap_state) 1097 { 1098 LDAP *ldap_struct = ldap_state->ldap_struct; 1098 1099 int rc; 1099 1100 int version; … … 1106 1107 if (!fetch_ldap_pw(&bind_dn, &bind_secret)) { 1107 1108 DEBUG(0, ("ldap_connect_system: Failed to retrieve password from secrets.tdb\n")); 1108 return LDAP_INVALID_CREDENTIALS; 1109 rc = LDAP_INVALID_CREDENTIALS; 1110 goto done; 1109 1111 } 1110 1112 smbldap_set_creds(ldap_state, false, bind_dn, bind_secret); … … 1152 1154 SAFE_FREE(ld_error); 1153 1155 ldap_state->num_failures++; 1154 return rc;1156 goto done; 1155 1157 } 1156 1158 … … 1167 1169 DEBUGADD(10, ("ldap_connect_system: LDAP server %s support paged results\n", 1168 1170 ldap_state->paged_results ? "does" : "does not")); 1171 done: 1172 if (rc != 0) { 1173 ldap_unbind(ldap_struct); 1174 ldap_state->ldap_struct = NULL; 1175 } 1169 1176 return rc; 1170 1177 } … … 1221 1228 } 1222 1229 1223 if ((rc = smbldap_connect_system(ldap_state, ldap_state->ldap_struct))) { 1224 ldap_unbind(ldap_state->ldap_struct); 1225 ldap_state->ldap_struct = NULL; 1230 if ((rc = smbldap_connect_system(ldap_state))) { 1226 1231 return rc; 1227 1232 } … … 1235 1240 if (ldap_state->event_context != NULL) { 1236 1241 ldap_state->idle_event = event_add_timed( 1237 ldap_state->event_context, NULL,1242 ldap_state->event_context, ldap_state, 1238 1243 timeval_current_ofs(SMBLDAP_IDLE_TIME, 0), 1239 1244 smbldap_idle_fn, ldap_state); … … 1259 1264 1260 1265 smbldap_delete_state(ldap_state); 1266 1267 TALLOC_FREE(ldap_state->idle_event); 1261 1268 1262 1269 DEBUG(5,("The connection to the LDAP server was closed\n")); … … 1746 1753 1747 1754 state->idle_event = event_add_timed( 1748 event_ctx, NULL,1755 event_ctx, state, 1749 1756 timeval_add(&now, SMBLDAP_IDLE_TIME, 0), 1750 1757 smbldap_idle_fn, … … 1772 1779 SAFE_FREE((*ldap_state)->bind_secret); 1773 1780 1774 TALLOC_FREE((*ldap_state)->idle_event); 1775 1776 *ldap_state = NULL; 1781 TALLOC_FREE(*ldap_state); 1777 1782 1778 1783 /* No need to free any further, as it is talloc()ed */ 1784 } 1785 1786 static int smbldap_state_destructor(struct smbldap_state *state) 1787 { 1788 smbldap_free_struct(&state); 1789 return 0; 1779 1790 } 1780 1791 … … 1802 1813 (*smbldap_state)->event_context = event_ctx; 1803 1814 1815 talloc_set_destructor(*smbldap_state, smbldap_state_destructor); 1804 1816 return NT_STATUS_OK; 1805 1817 }
Note:
See TracChangeset
for help on using the changeset viewer.