diff --git a/src/TRLDAPConnection.h b/src/TRLDAPConnection.h index 832ed97..24f0b2f 100644 --- a/src/TRLDAPConnection.h +++ b/src/TRLDAPConnection.h @@ -54,8 +54,8 @@ scope: (int) scope baseDN: (TRString *) base attributes: (TRArray *) attributes; -- (BOOL) compareDN: (TRString *) dn withAttribute: (TRString *) attribute value: (TRString *) value; - (BOOL) compare: (TRString *) dn withAttribute: (TRString *) attribute value: (TRString *) value; +- (BOOL) compareDN: (TRString *) dn withAttribute: (TRString *) attribute value: (TRString *) value; - (BOOL) setReferralEnabled: (BOOL) enabled; - (BOOL) setTLSCACertFile: (TRString *) fileName; diff --git a/src/TRLDAPConnection.m b/src/TRLDAPConnection.m index 40dd23d..097f201 100644 --- a/src/TRLDAPConnection.m +++ b/src/TRLDAPConnection.m @@ -273,51 +273,6 @@ - (BOOL) bindWithDN: (TRString *) bindDN password: (TRString *) password { int numEntries; int err; -- (BOOL) compare: (TRString *) dn withAttribute: (TRString *) attribute value: (TRString *) value { - struct timeval timeout; - LDAPMessage *res; - struct berval bval; - int err; - int msgid; - - /* Set up the ber structure for our value */ - bval.bv_val = (char *) [value cString]; - bval.bv_len = [value length] - 1; /* Length includes NULL terminator */ - - /* Set up the timeout */ - timeout.tv_sec = _timeout; - timeout.tv_usec = 0; - - /* Perform the compare */ - if ((err = ldap_compare_ext(ldapConn, [dn cString], [attribute cString], &bval, NULL, NULL, &msgid)) != LDAP_SUCCESS) { - [TRLog debug: "LDAP compare failed: %d: %s", err, ldap_err2string(err)]; - return NO; - } - - /* Wait for the result */ - if (ldap_result(ldapConn, msgid, 1, &timeout, &res) == -1) { - err = ldap_get_errno(ldapConn); - if (err == LDAP_TIMEOUT) - ldap_abandon_ext(ldapConn, msgid, NULL, NULL); - - [TRLog debug: "ldap_compare_ext failed: %s", ldap_err2string(err)]; - return NO; - } - - /* Check the result */ - if (ldap_parse_result(ldapConn, res, &err, NULL, NULL, NULL, NULL, 1) != LDAP_SUCCESS) { - /* Parsing failed */ - return NO; - } - if (err == LDAP_COMPARE_TRUE) - return YES; - else - return NO; - - return NO; -} - - count = 0; entries = nil; @@ -438,6 +393,50 @@ - (BOOL) compare: (TRString *) dn withAttribute: (TRString *) attribute value: ( return [entries autorelease]; } +- (BOOL) compare: (TRString *) dn withAttribute: (TRString *) attribute value: (TRString *) value { + struct timeval timeout; + LDAPMessage *res; + struct berval bval; + int err; + int msgid; + + /* Set up the ber structure for our value */ + bval.bv_val = (char *) [value cString]; + bval.bv_len = [value length] - 1; /* Length includes NULL terminator */ + + /* Set up the timeout */ + timeout.tv_sec = _timeout; + timeout.tv_usec = 0; + + /* Perform the compare */ + if ((err = ldap_compare_ext(ldapConn, [dn cString], [attribute cString], &bval, NULL, NULL, &msgid)) != LDAP_SUCCESS) { + [TRLog debug: "LDAP compare failed: %d: %s", err, ldap_err2string(err)]; + return NO; + } + + /* Wait for the result */ + if (ldap_result(ldapConn, msgid, 1, &timeout, &res) == -1) { + err = ldap_get_errno(ldapConn); + if (err == LDAP_TIMEOUT) + ldap_abandon_ext(ldapConn, msgid, NULL, NULL); + + [TRLog debug: "ldap_compare_ext failed: %s", ldap_err2string(err)]; + return NO; + } + + /* Check the result */ + if (ldap_parse_result(ldapConn, res, &err, NULL, NULL, NULL, NULL, 1) != LDAP_SUCCESS) { + /* Parsing failed */ + return NO; + } + if (err == LDAP_COMPARE_TRUE) + return YES; + else + return NO; + + return NO; +} + - (BOOL) compareDN: (TRString *) dn withAttribute: (TRString *) attribute value: (TRString *) value { struct timeval timeout; LDAPMessage *res; diff --git a/src/TRLDAPGroupConfig.m b/src/TRLDAPGroupConfig.m index fd703ad..c51afc6 100644 --- a/src/TRLDAPGroupConfig.m +++ b/src/TRLDAPGroupConfig.m @@ -53,6 +53,14 @@ - (void) dealloc { [super dealloc]; } +- (id) init { + self = [super init]; + if (self == nil) + return self; + + _memberRFC2307BIS = YES; + return self; +} - (TRString *) baseDN { return (_baseDN);