hi,

attached is a patch for the net-tool that makes the default 
dn-component "cn=Users" selectable with a "-c|--container"-switch 
upon creation of groups and users in ADS.

the patch applies to HEAD and 3_0.

bye,
guenther

-- 
Guenther Deschner                                         [EMAIL PROTECTED]
SuSE Linux AG                                        GnuPG: 8EE11688
Berliner Str. 27                      phone:  +49 (0) 30 / 430944778
D-13507 Berlin                           fax:  +49 (0) 30 / 43732804
diff -Nur source/utils/net.c source/utils/net.c
--- source/utils/net.c  Fri Sep 27 09:42:34 2002
+++ source/utils/net.c  Tue Oct  1 12:22:00 2002
@@ -68,6 +68,7 @@
 int opt_port = 0;
 int opt_maxusers = -1;
 char *opt_comment = "";
+char *opt_container = "cn=Users";
 int opt_flags = -1;
 int opt_jobid = 0;
 int opt_timeout = 0;
@@ -459,6 +460,7 @@
                {"myname",      'n', POPT_ARG_STRING, &opt_requester_name},
                {"conf",        's', POPT_ARG_STRING, &servicesf},
                {"server",      'S', POPT_ARG_STRING, &opt_host},
+               {"container",   'c', POPT_ARG_STRING, &opt_container},
                {"comment",     'C', POPT_ARG_STRING, &opt_comment},
                {"maxusers",    'M', POPT_ARG_INT,    &opt_maxusers},
                {"flags",       'F', POPT_ARG_INT,    &opt_flags},
diff -Nur source/utils/net.h source/utils/net.h
--- source/utils/net.h  Tue Jun 25 04:29:09 2002
+++ source/utils/net.h  Tue Oct  1 12:19:51 2002
@@ -38,10 +38,8 @@
 
 extern int opt_maxusers;
 extern char *opt_comment;
+extern char *opt_container;
 extern int opt_flags;
-
-extern char *opt_comment;
-
 extern char *opt_target_workgroup;
 extern int opt_long_list_entries;
 extern int opt_reboot;
diff -Nur source/utils/net_ads.c source/utils/net_ads.c
--- source/utils/net_ads.c      Tue Sep 17 14:15:52 2002
+++ source/utils/net_ads.c      Tue Oct  1 12:33:44 2002
@@ -255,7 +255,7 @@
                goto done;
        }
 
-       status = ads_add_user_acct(ads, argv[0], opt_comment);
+       status = ads_add_user_acct(ads, argv[0], opt_container, opt_comment);
 
        if (!ADS_ERR_OK(status)) {
                d_printf("Could not add user %s: %s\n", argv[0],
@@ -431,7 +431,7 @@
                goto done;
        }
 
-       status = ads_add_group_acct(ads, argv[0], opt_comment);
+       status = ads_add_group_acct(ads, argv[0], opt_container, opt_comment);
 
        if (ADS_ERR_OK(status)) {
                d_printf("Group %s added\n", argv[0]);
diff -Nur source/utils/net_help.c source/utils/net_help.c
--- source/utils/net_help.c     Tue Sep 24 20:10:30 2002
+++ source/utils/net_help.c     Tue Oct  1 13:01:50 2002
@@ -69,13 +69,13 @@
                 "\n\tDelete specified user\n");
        d_printf("\nnet <method> user INFO <name> [misc. options] [targets]"\
                 "\n\tList the domain groups of the specified user\n");
-       d_printf("\nnet <method> user ADD <name> [password] [-F user flags] [misc. 
options]"\
+       d_printf("\nnet <method> user ADD <name> [password] [-F user flags] [-c 
+container] [misc. options]"\
                 " [targets]\n\tAdd specified user\n");
 
        net_common_methods_usage(argc, argv);
        net_common_flags_usage(argc, argv);
-       d_printf(
-        "\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
+       d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
+       d_printf("\t-c or --container=<container>\tLDAP container, defaults to 
+cn=Users (for add in ADS only)\n");
        return -1;
 }
 
@@ -85,12 +85,12 @@
                 "\n\tList user groups\n\n");
        d_printf("net <method> group DELETE <name> [misc. options] [targets]"\
                 "\n\tDelete specified group\n");
-       d_printf("\nnet <method> group ADD <name> [-C comment]"\
+       d_printf("\nnet <method> group ADD <name> [-C comment] [-c container]"\
                 " [misc. options] [targets]\n\tCreate specified group\n");
        net_common_methods_usage(argc, argv);
        net_common_flags_usage(argc, argv);
-       d_printf(
-        "\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
+       d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
+       d_printf("\t-c or --container=<container>\tLDAP container, defaults to 
+cn=Users (for add in ADS only)\n");
        return -1;
 }
 
diff -Nur source/libads/ldap_user.c source/libads/ldap_user.c
--- source/libads/ldap_user.c   Wed Aug  7 12:33:22 2002
+++ source/libads/ldap_user.c   Tue Oct  1 12:46:08 2002
@@ -38,7 +38,7 @@
 }
 
 ADS_STATUS ads_add_user_acct(ADS_STRUCT *ads, const char *user, 
-                            const char *fullname)
+                            const char *container, const char *fullname)
 {
        TALLOC_CTX *ctx;
        ADS_MODLIST mods;
@@ -57,7 +60,7 @@
 
        if (!(upn = talloc_asprintf(ctx, "%s@%s", user, ads->config.realm)))
                goto done;
-       if (!(new_dn = talloc_asprintf(ctx, "cn=%s,cn=Users,%s", name, 
+       if (!(new_dn = talloc_asprintf(ctx, "cn=%s,%s,%s", name, container,
                                       ads->config.bind_path)))
                goto done;
        if (!(controlstr = talloc_asprintf(ctx, "%u", UF_NORMAL_ACCOUNT)))
@@ -80,7 +83,7 @@
 }
 
 ADS_STATUS ads_add_group_acct(ADS_STRUCT *ads, const char *group, 
-                             const char *comment)
+                             const char *container, const char *comment)
 {
        TALLOC_CTX *ctx;
        ADS_MODLIST mods;
@@ -93,7 +96,7 @@
 
        status = ADS_ERROR(LDAP_NO_MEMORY);
 
-       if (!(new_dn = talloc_asprintf(ctx, "cn=%s,cn=Users,%s", group, 
+       if (!(new_dn = talloc_asprintf(ctx, "cn=%s,%s,%s", group, container,
                                       ads->config.bind_path)))
                goto done;
        if (!(mods = ads_init_mods(ctx)))
@@ -102,7 +105,7 @@
        ads_mod_str(ctx, &mods, "cn", group);
        ads_mod_strlist(ctx, &mods, "objectClass",objectClass);
        ads_mod_str(ctx, &mods, "name", group);
-       if (comment)
+       if (comment && *comment) 
                ads_mod_str(ctx, &mods, "description", comment);
        ads_mod_str(ctx, &mods, "sAMAccountName", group);
        status = ads_gen_add(ads, new_dn, mods);

Attachment: msg03399/pgp00000.pgp
Description: PGP signature

Reply via email to