+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
/*
* Copyright (c) 1993, 1994 Regents of the University of Michigan.
* All rights reserved.
#include "portable.h"
#include <stdio.h>
-#include <string.h>
-#include <time.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
#include <lber.h>
#include <ldap.h>
-#include <ldapconfig.h>
+#include "ldap_defaults.h"
#include "ud.h"
-extern LDAPMessage * find();
-
-#ifdef DEBUG
-extern int debug;
-#endif
-
-extern char *bound_dn, *group_base;
-extern int verbose, bind_status;
-extern struct entry Entry;
-extern LDAP *ld;
+static char * bind_and_fetch(char *name);
-extern void Free();
-void add_group(name)
-char *name;
+void
+add_group( char *name )
{
- register int i, idx = 0, prompt = 0;
+ int idx = 0, prompt = 0;
char tmp[BUFSIZ], dn[BUFSIZ];
static LDAPMod *attrs[9];
LDAPMod init_rdn, init_owner, init_domain,
char *init_rdn_value[2], *init_owner_value[2], *init_domain_value[2],
*init_errors_value[MAX_VALUES], *init_joinable_value[2],
*init_request_value[MAX_VALUES];
- extern void ldap_flush_cache();
- extern char * strip_ignore_chars();
#ifdef DEBUG
if (debug & D_TRACE) {
#ifdef DEBUG
if (debug & D_GROUPS) {
- register LDAPMod **lpp;
- register char **cpp;
- register int j;
- extern char * code_to_str();
+ LDAPMod **lpp;
+ char **cpp;
+ int i, j;
printf(" About to call ldap_add()\n");
printf(" ld = 0x%x\n", ld);
printf(" dn = [%s]\n", dn);
return;
}
-void remove_group(name)
-char *name;
+void
+remove_group( char *name )
{
char *dn, tmp[BUFSIZ];
- static char * bind_and_fetch();
#ifdef DEBUG
if (debug & D_TRACE) {
if ((dn = bind_and_fetch(name)) == NULL)
return;
- printf("\n The group '%s' will be permanently removed from\n",
- name);
- printf(" the Directory. Are you absolutely sure that you want to\n" ); printf(" remove this entire group? ");
+ printf("\n The entry\n '%s'\n will be permanently removed from", dn);
+ printf(" the Directory.\n Are you absolutely sure that you want to" );
+ printf(" remove this entire group? ");
fflush(stdout);
fetch_buffer(tmp, sizeof(tmp), stdin);
if (!(tmp[0] == 'y' || tmp[0] == 'Y'))
* Now remove this from the LDAP Directory.
*/
if (ldap_delete_s(ld, dn) != 0) {
- if (ld->ld_errno == LDAP_INSUFFICIENT_ACCESS)
- printf(" You do not own the group \"%s\".\n", name);
+ int ld_errno = 0;
+ ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+ if (ld_errno == LDAP_INSUFFICIENT_ACCESS)
+ printf(" You do not own the entry\n\t\"%s\".\n", dn);
else
ldap_perror(ld, " ldap_delete_s");
printf(" Group not removed.\n");
}
ldap_uncache_entry(ld, dn);
if (verbose)
+ {
if (name == NULL)
printf(" The group has been removed.\n");
else
printf(" The group \"%s\" has been removed.\n", name);
+ }
Free(dn);
return;
}
-void x_group(action, name)
-int action;
-char *name;
+void
+x_group( int action, char *name )
{
char **vp;
char *values[2], *group_name;
LDAPMod mod, *mods[2];
static char *actions[] = { "join", "resign from", NULL };
- static char * bind_and_fetch();
#ifdef DEBUG
if (debug & D_TRACE) {
#endif
if (ldap_modify_s(ld, bound_dn, mods)) {
- if ((action == G_JOIN) && (ld->ld_errno == LDAP_TYPE_OR_VALUE_EXISTS))
+ int ld_errno = 0;
+ ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+ if ((action == G_JOIN) && (ld_errno == LDAP_TYPE_OR_VALUE_EXISTS))
printf(" You are already subscribed to \"%s\"\n", group_name);
- else if ((action == G_RESIGN) && (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE))
+ else if ((action == G_RESIGN) && (ld_errno == LDAP_NO_SUCH_ATTRIBUTE))
printf(" You are not subscribed to \"%s\"\n", group_name);
else
mod_perror(ld);
return;
}
-void bulk_load(group)
-char *group;
+void
+bulk_load( char *group )
{
register int idx_mail, idx_x500;
register int count_mail, count_x500;
return;
}
-void purge_group(group)
-char *group;
+void
+purge_group( char *group )
{
int isclean = TRUE;
LDAPMessage *lm;
LDAPMod mod, *mods[2];
char dn[BUFSIZ], tmp[BUFSIZ], *values[2], **vp, **rdns;
- extern char * my_ldap_dn2ufn();
- extern int col_size;
#ifdef DEBUG
if (debug & D_TRACE) {
return;
}
-void tidy_up()
+void
+tidy_up( void )
{
register int i = 0;
int found_one = 0;
* Names or e-mail addresses. This includes things like group members,
* the errors-to field in groups, and so on.
*/
-void mod_addrDN(group, offset)
-char *group;
-int offset;
+void
+mod_addrDN( char *group, int offset )
{
- extern struct attribute attrlist[];
char s[BUFSIZ], *new_value /* was member */, *values[2];
char attrtype[ 64 ];
- int i;
LDAPMod mod, *mods[2];
LDAPMessage *mp;
* "Bryan Beecher" <bryan@umich.edu>
* Bryan Beecher <bryan@umich.edu>
*/
- register char *cp;
+ char *cp;
if (strchr(s, '<') == NULL) {
for (cp = s; *cp != '@'; cp++)
- if (isspace(*cp))
+ if (isspace((unsigned char)*cp))
*cp = '.';
}
new_value = s;
#ifdef DEBUG
if (debug & D_GROUPS) {
- register LDAPMod **lpp;
- register char **cp;
- register int i, j;
+ LDAPMod **lpp;
+ char **cp;
+ int i, j;
printf(" About to call ldap_modify_s()\n");
printf(" ld = 0x%x\n", ld);
printf(" dn = [%s]\n", group);
#endif
if (my_ldap_modify_s(ld, group, mods)) {
- if (ld->ld_errno == LDAP_NO_SUCH_ATTRIBUTE) {
+ int ld_errno = 0;
+ ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+ if (ld_errno == LDAP_NO_SUCH_ATTRIBUTE) {
printf(" Could not locate value \"%s\"\n",
new_value);
continue;
mod.mod_op = LDAP_MOD_DELETE;
#ifdef DEBUG
if (debug & D_GROUPS) {
- register LDAPMod **lpp;
- register char **cp;
- register int i, j;
+ LDAPMod **lpp;
+ char **cp;
+ int i, j;
printf(" About to call ldap_modify_s()\n");
printf(" ld = 0x%x\n", ld);
printf(" dn = [%s]\n", group);
* A "No such attribute" error is no big deal.
* We only wanted to clear the attribute anyhow.
*/
- if (ld->ld_errno != LDAP_NO_SUCH_ATTRIBUTE) {
+ int ld_errno = 0;
+ ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
+ if (ld_errno != LDAP_NO_SUCH_ATTRIBUTE) {
mod_perror(ld);
return;
}
}
}
-my_ldap_modify_s(ldap, group, mods)
-LDAP *ldap;
-char *group;
-LDAPMod *mods[];
+int
+my_ldap_modify_s( LDAP *ldap, char *group, LDAPMod **mods )
{
int was_rfc822member, rc;
return(rc);
}
-void list_groups(who)
-char *who;
+void
+list_groups( char *who )
{
LDAPMessage *mp;
char name[BUFSIZ], filter[BUFSIZ], *search_attrs[2];
/* lookup the groups belonging to this person */
sprintf(filter, "owner=%s", dn);
- Free(dn);
+ ldap_memfree(dn);
search_attrs[0] = "cn";
search_attrs[1] = NULL;
if ((rc = ldap_search_s(ld, UD_WHERE_ALL_GROUPS_LIVE, LDAP_SCOPE_SUBTREE,
return;
}
-static char * bind_and_fetch(name)
-char *name;
+static char *
+bind_and_fetch( char *name )
{
LDAPMessage *lm;
char tmp[MED_BUF_SIZE];
- extern char * strip_ignore_chars();
#ifdef DEBUG
if (debug & D_TRACE) {
return(strdup(Entry.DN));
}
-void list_memberships(who)
-char *who;
+void
+list_memberships( char *who )
{
LDAPMessage *mp;
char name[BUFSIZ], filter[BUFSIZ], *search_attrs[2];
/* lookup the groups belonging to this person */
sprintf(filter, "member=%s", dn);
- Free(dn);
+ ldap_memfree(dn);
search_attrs[0] = "cn";
search_attrs[1] = NULL;
ldap_msgfree(mp);