]> git.sur5r.net Git - openldap/blobdiff - clients/ud/group.c
Don't depend error handling on exact resultCode.
[openldap] / clients / ud / group.c
index e9c9c49cde10ea597474ef2269202ee5c4632394..16a0b6d0fecb41d83446b34f62ef6eaa7a0b2666 100644 (file)
@@ -1,3 +1,8 @@
+/* $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 <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"
 
 static char * bind_and_fetch(char *name);
@@ -31,7 +41,7 @@ static char * bind_and_fetch(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,
@@ -152,9 +162,9 @@ add_group( char *name )
 
 #ifdef DEBUG
        if (debug & D_GROUPS) {
-               register LDAPMod **lpp;
-               register char **cpp;
-               register int j;
+               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);
@@ -209,9 +219,9 @@ remove_group( char *name )
        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'))
@@ -224,7 +234,7 @@ remove_group( char *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 group \"%s\".\n", name);
+                       printf("  You do not own the entry\n\t\"%s\".\n", dn);
                else
                        ldap_perror(ld, "  ldap_delete_s");
                printf("  Group not removed.\n");
@@ -233,10 +243,12 @@ remove_group( char *name )
        }
        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;
 }
@@ -728,7 +740,6 @@ mod_addrDN( char *group, int offset )
 {
        char s[BUFSIZ], *new_value /* was member */, *values[2];
        char attrtype[ 64 ];
-       int i;
        LDAPMod mod, *mods[2];
        LDAPMessage *mp;
 
@@ -867,10 +878,10 @@ mod_addrDN( char *group, int offset )
                         *      "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;
@@ -895,9 +906,9 @@ mod_addrDN( char *group, int offset )
 
 #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);
@@ -954,9 +965,9 @@ mod_addrDN( char *group, int offset )
                        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);
@@ -1063,7 +1074,7 @@ list_groups( char *who )
 
        /* 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, 
@@ -1196,7 +1207,7 @@ list_memberships( char *who )
 
        /* 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);