Skip to content

Commit

Permalink
Fixed apparently broken merge, default memberRFC2307BIS to YES.
Browse files Browse the repository at this point in the history
  • Loading branch information
samskivert committed Jan 25, 2017
1 parent 5e14aed commit 37137c5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/TRLDAPConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
89 changes: 44 additions & 45 deletions src/TRLDAPConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/TRLDAPGroupConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 37137c5

Please sign in to comment.