Commit 0624a31c authored by Randy Kunkee's avatar Randy Kunkee
Browse files

Fix several bugs with dereferencing aliases and create 'compare' subcommand.

parent 3cfb6b3b
...@@ -797,7 +797,7 @@ NeoX_LdapTargetObjCmd (clientData, interp, objc, objv) ...@@ -797,7 +797,7 @@ NeoX_LdapTargetObjCmd (clientData, interp, objc, objv)
deref = LDAP_DEREF_NEVER; deref = LDAP_DEREF_NEVER;
else if (STREQU(derefString, "search")) else if (STREQU(derefString, "search"))
deref = LDAP_DEREF_SEARCHING; deref = LDAP_DEREF_SEARCHING;
else if (STREQU(derefString, "find") == 0) else if (STREQU(derefString, "find"))
deref = LDAP_DEREF_FINDING; deref = LDAP_DEREF_FINDING;
else if (STREQU(derefString, "always")) else if (STREQU(derefString, "always"))
deref = LDAP_DEREF_ALWAYS; deref = LDAP_DEREF_ALWAYS;
...@@ -886,6 +886,9 @@ NeoX_LdapTargetObjCmd (clientData, interp, objc, objv) ...@@ -886,6 +886,9 @@ NeoX_LdapTargetObjCmd (clientData, interp, objc, objv)
ldap_disable_cache(ldap); ldap_disable_cache(ldap);
} }
#endif #endif
ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
tclResult = LDAP_PerformSearch (interp, tclResult = LDAP_PerformSearch (interp,
ldaptcl, ldaptcl,
baseString, baseString,
...@@ -907,10 +910,42 @@ NeoX_LdapTargetObjCmd (clientData, interp, objc, objv) ...@@ -907,10 +910,42 @@ NeoX_LdapTargetObjCmd (clientData, interp, objc, objv)
else else
ldap_enable_cache(ldap, ldaptcl->timeout, ldaptcl->maxmem); ldap_enable_cache(ldap, ldaptcl->timeout, ldaptcl->maxmem);
} }
deref = LDAP_DEREF_NEVER;
ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
#endif #endif
return tclResult; return tclResult;
} }
/* object compare dn attr value */
if (STREQU (subCommand, "compare")) {
char *dn;
char *attr;
char *value;
int result;
int lderrno;
if (objc != 5)
return TclX_WrongArgs (interp,
objv [0],
"compare dn attribute value");
dn = Tcl_GetStringFromObj (objv[2], NULL);
attr = Tcl_GetStringFromObj (objv[3], NULL);
value = Tcl_GetStringFromObj (objv[4], NULL);
result = ldap_compare_s (ldap, dn, attr, value);
if (result == LDAP_COMPARE_TRUE || result == LDAP_COMPARE_FALSE) {
Tcl_SetIntObj(resultObj, result == LDAP_COMPARE_TRUE);
return TCL_OK;
}
LDAP_SetErrorCode(ldaptcl, result, interp);
Tcl_AppendStringsToObj (resultObj,
"LDAP compare error: ",
LDAP_ERR_STRING(ldap),
(char *)NULL);
return TCL_ERROR;
}
#if defined(UMICH_LDAP) || (defined(OPEN_LDAP) && !defined(LDAP_API_VERSION)) #if defined(UMICH_LDAP) || (defined(OPEN_LDAP) && !defined(LDAP_API_VERSION))
if (STREQU (subCommand, "cache")) { if (STREQU (subCommand, "cache")) {
char *cacheCommand; char *cacheCommand;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment