[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LDAP directory patch
LDAP Patch attached.
Dean.
> > What is the etiquette in this list. do I post the patch here?
>
> You can post them to the list, and alternatively you can
> just email them to me,
> /Matti Aarnio <mea@nic.funet.fi>
*** zmailer-2-cvs/router/libdb/ldap.c.orig Fri Oct 9 16:31:36 1998
--- zmailer-2-cvs/router/libdb/ldap.c Thu Feb 4 12:26:36 1999
***************
*** 23,28 ****
--- 23,29 ----
int scope;
char *filter;
char *attr;
+ int wildcards;
} LDAPMAP;
extern int deferit;
***************
*** 64,69 ****
--- 65,71 ----
lmap->ldaphost = NULL;
lmap->ldapport = LDAP_PORT;
+ lmap->wildcards = 0;
lmap->base = NULL;
lmap->binddn = NULL;
lmap->passwd = NULL;
***************
*** 135,140 ****
--- 137,149 ----
else if (strncasecmp(p, "sub", 3) == 0)
lmap->scope = LDAP_SCOPE_SUBTREE;
}
+ else if (strncasecmp(p, "wildcards", 9) == 0) {
+ p += 9;
+ while (isascii(*++p) && isspace(*p))
+ continue;
+ if (strncasecmp(p, "true", 4) == 0)
+ lmap->wildcards = 1;
+ }
}
fclose(fp);
}
***************
*** 155,160 ****
--- 164,174 ----
char filter[LDAP_FILT_MAXSIZ + 1];
char **vals = NULL;
char *attrs[] = {NULL, NULL};
+ char *filterstring = NULL;
+ int starcount = 0;
+ int filterlength = 0;
+ int counter = 0;
+ int filterpos = 0;
conscell *tmp;
u_char *us = NULL;
***************
*** 174,180 ****
goto ldap_exit;
}
! sprintf(filter, lmap->filter, (char *)sip->key);
attrs[0] = lmap->attr;
if (ldap_search_s(ld, lmap->base, lmap->scope, filter,
attrs, 0, &msg) != LDAP_SUCCESS) {
--- 188,228 ----
goto ldap_exit;
}
! filterstring = (char *)sip->key;
!
! if (!lmap->wildcards) {
! filterlength = strlen(filterstring);
!
! for (counter = 0; counter < filterlength; counter++) {
! if (filterstring[counter] == '*') {
! starcount++;
! }
! }
!
! if (starcount) {
! filterstring = malloc(filterlength + 2*starcount + 1);
! filterpos = 0;
! counter = 0;
! for (; counter < filterlength; ) {
! if (((char *)sip->key)[counter] == '*') {
! filterstring[filterpos++] = '\\';
! filterstring[filterpos++] = '2';
! filterstring[filterpos++] = 'a';
! } else {
! filterstring[filterpos++] = ((char *)sip->key)[counter];
! }
! counter++;
! }
! filterstring[filterpos] = 0;
! }
! }
!
! sprintf(filter, lmap->filter, filterstring);
!
! if (!lmap->wildcards && starcount) {
! free(filterstring);
! }
!
attrs[0] = lmap->attr;
if (ldap_search_s(ld, lmap->base, lmap->scope, filter,
attrs, 0, &msg) != LDAP_SUCCESS) {