+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
/*
* Copyright (c) 1991, 1992, 1993
* Regents of the University of Michigan. All rights reserved.
#include "portable.h"
#include <stdio.h>
-#include <stdlib.h>
+
+#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
-extern char *strdup (const char *);
-#include <lber.h>
#include <ldap.h>
#include "ud.h"
int
vrfy( char *dn )
{
- LDAPMessage *results;
- static char *attrs[2] = { "objectClass", NULL };
+ LDAPMessage *results = NULL;
+ static char *attrs[2] = { "1.1", NULL };
int ld_errno = 0;
#ifdef DEBUG
printf("->vrfy(%s)\n", dn);
#endif
/* verify that this DN exists in the directory */
- (void) ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", attrs, TRUE, &results);
+ (void) ldap_search_s(ld, dn, LDAP_SCOPE_BASE, NULL, attrs, TRUE, &results);
(void) ldap_msgfree(results);
ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
char *namelist[MAX_NUM_NAMES]; /* names found */
char response[SMALL_BUF_SIZE]; /* results from user */
char *name = NULL; /* DN to lookup */
- LDAPMessage *mp;
+ LDAPMessage *mp = NULL;
int ld_errno = 0;
#ifdef DEBUG
for (;;) {
printf(" Do you wish to see a list of names? ");
fflush(stdout);
- (void) memset(response, 0, sizeof(response));
+ (void) memset(response, '\0', sizeof(response));
fetch_buffer(response, sizeof(response), stdin);
switch (response[0]) {
case 'n' :
printf(" ld = 0x%x\n", ld);
printf(" search base = %s\n", name);
printf(" scope = LDAP_SCOPE_BASE\n");
- printf(" filter = objectClass=*\n");
+ printf(" filter = (objectClass=*)\n");
for (i = 0; read_attrs[i] != NULL; i++)
printf(" read_attrs[%d] = %s\n", i, read_attrs[i]);
printf(" read_attrs[%d] = NULL\n", i);
printf(" &mp = 0x%x\n", &mp);
}
#endif
- if (ldap_search_s(ld, name, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &mp) != LDAP_SUCCESS) {
+ if (ldap_search_s(ld, name, LDAP_SCOPE_BASE, NULL, read_attrs, FALSE, &mp) != LDAP_SUCCESS) {
ldap_perror(ld, "ldap_search_s");
Free(name);
ldap_msgfree(mp);
search_attrs[k] = NULL;
}
- /*
- * If the user-supplied name has any commas in it, we
- * assume that it is a UFN, and do everything right
- * here. If we don't find it, treat it as NOT a UFN.
- */
- if (strchr(who, ',') != NULL) {
- int savederef, deref;
-#ifdef DEBUG
- if (debug & D_FIND)
- printf("\"%s\" appears to be a UFN\n", who);
-#endif
- ldap_get_option(ld, LDAP_OPT_DEREF, &savederef);
- deref = LDAP_DEREF_FINDING;
- ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
-
- if ((rc = ldap_ufn_search_s(ld, who, search_attrs, FALSE, &res)) !=
- LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED &&
- rc != LDAP_TIMELIMIT_EXCEEDED) {
- ldap_perror(ld, "ldap_ufn_search_s");
- ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
- return(NULL);
- }
- if ((matches = ldap_count_entries(ld, res)) < 0) {
- ldap_perror(ld, "ldap_count_entries");
- ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
- return(NULL);
- } else if (matches == 1) {
- dn = ldap_get_dn(ld, ldap_first_entry(ld, res));
- rc = ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res);
- Free(dn);
- if (rc != LDAP_SUCCESS) {
- int ld_errno = 0;
- ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
- if (ld_errno == LDAP_UNAVAILABLE)
- printf(" Could not contact the LDAP server to find \"%s\".\n", who);
- else
- ldap_perror(ld, "ldap_search_s");
- return(NULL);
- }
- ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
- return(res);
- } else if (matches > 1 ) {
- return disambiguate( res, matches, read_attrs, who );
- }
- ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
- }
-
/*
* Old users of the MTS *USERDIRECTORY will likely wrap the name
* in quotes. Not only is this unnecessary, but it also won't work.
break;
}
- /*
- * It wasn't a UFN, so look it up in the usual method.
- */
for (fi = ldap_getfirstfilter(lfdp, "ud", who); fi != NULL;
fi = ldap_getnextfilter(lfdp)) {
#ifdef DEBUG
fetch_buffer(response, sizeof(response), stdin);
if ((response[0] == 'n') || (response[0] == 'N'))
{
- Free(dn);
+ ldap_memfree(dn);
return(NULL);
}
}
printf(" ld = 0x%x\n", ld);
printf(" dn = %s\n", dn);
printf(" scope = LDAP_SCOPE_BASE\n");
- printf(" filter = %s\n", "objectClass=*");
+ printf(" filter = %s\n", "(objectClass=*)");
for (i = 0; read_attrs[i] != NULL; i++)
printf(" read_attrs[%d] = %s\n", i, read_attrs[i]);
printf(" read_attrs[%d] = NULL\n", i);
printf(" &results = 0x%x\n", &res);
}
#endif
- if (ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res) != LDAP_SUCCESS) {
+ if (ldap_search_s(ld, dn, LDAP_SCOPE_BASE, NULL, read_attrs, FALSE, &res) != LDAP_SUCCESS) {
ldap_perror(ld, "ldap_search_s");
ldap_msgfree(res);
res = NULL;
}
- Free(dn);
+ ldap_memfree(dn);
return(res);
}
else if (matches > 0) {
printf("->fetch_boolean_value(%s, %s)\n", who, attr.quipu_name);
#endif
attributes[0] = attr.quipu_name;
- if (ldap_search_s(ld, who, LDAP_SCOPE_BASE, "objectClass=*", attributes, FALSE, &result) != LDAP_SUCCESS) {
+ if (ldap_search_s(ld, who, LDAP_SCOPE_BASE, NULL, attributes, FALSE, &result) != LDAP_SUCCESS) {
int ld_errno = 0;
ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
if (ld_errno == LDAP_NO_SUCH_ATTRIBUTE)