LDAP           *ld = NULL;
        struct berval *bv = NULL;
 
-       int id, code;
+       int id, code = LDAP_OTHER;
        LDAPMessage *res;
        char *matcheddn = NULL, *text = NULL, **refs = NULL;
        char    *retoid = NULL;
        /* disconnect from server */
        ldap_unbind (ld);
 
-       return EXIT_SUCCESS;
+       return code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
        LDAP           *ld = NULL;
        struct berval *bv = NULL;
 
-       int id, code;
+       int id, code = LDAP_OTHER;
        LDAPMessage *res;
        char *matcheddn = NULL, *text = NULL, **refs = NULL;
        char    *retoid = NULL;
        /* disconnect from server */
        ldap_unbind (ld);
 
-       return EXIT_SUCCESS;
+       return code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
 }