s3-rpc_misc: clean out include/rpc_misc.h.
[samba.git] / source3 / utils / net_groupmap.c
index b160d840a07995cc27de803e8bd18d0464def814..9b46808b8b4c84fe9af770094623228e45779685 100644 (file)
@@ -35,14 +35,16 @@ static bool get_sid_from_input(DOM_SID *sid, char *input)
        if (StrnCaseCmp( input, "S-", 2)) {
                /* Perhaps its the NT group name? */
                if (!pdb_getgrnam(&map, input)) {
-                       printf("NT Group %s doesn't exist in mapping DB\n", input);
+                       printf(_("NT Group %s doesn't exist in mapping DB\n"),
+                              input);
                        return false;
                } else {
                        *sid = map.sid;
                }
        } else {
                if (!string_to_sid(sid, input)) {
-                       printf("converting sid %s from a string failed!\n", input);
+                       printf(_("converting sid %s from a string failed!\n"),
+                              input);
                        return false;
                }
        }
@@ -60,12 +62,12 @@ static void print_map_entry ( GROUP_MAP map, bool long_list )
                         sid_string_tos(&map.sid), gidtoname(map.gid));
        else {
                d_printf("%s\n", map.nt_name);
-               d_printf("\tSID       : %s\n", sid_string_tos(&map.sid));
-               d_printf("\tUnix gid  : %d\n", map.gid);
-               d_printf("\tUnix group: %s\n", gidtoname(map.gid));
-               d_printf("\tGroup type: %s\n",
+               d_printf(_("\tSID       : %s\n"), sid_string_tos(&map.sid));
+               d_printf(_("\tUnix gid  : %u\n"), (unsigned int)map.gid);
+               d_printf(_("\tUnix group: %s\n"), gidtoname(map.gid));
+               d_printf(_("\tGroup type: %s\n"),
                         sid_type_lookup(map.sid_name_use));
-               d_printf("\tComment   : %s\n", map.comment);
+               d_printf(_("\tComment   : %s\n"), map.comment);
        }
 
 }
@@ -79,14 +81,14 @@ static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
        size_t i;
        fstring ntgroup = "";
        fstring sid_string = "";
-       const char list_usage_str[] = "net groupmap list [verbose] "
-                                     "[ntgroup=NT group] [sid=SID]\n"
-                                     "    verbose\tPrint verbose list\n"
-                                     "    ntgroup\tNT group to list\n"
-                                     "    sid\tSID of group to list";
+       const char list_usage_str[] = N_("net groupmap list [verbose] "
+                                        "[ntgroup=NT group] [sid=SID]\n"
+                                        "    verbose\tPrint verbose list\n"
+                                        "    ntgroup\tNT group to list\n"
+                                        "    sid\tSID of group to list");
 
        if (c->display_usage) {
-               d_printf("Usage:\n%s\n", list_usage_str);
+               d_printf("%s\n%s\n", _("Usage: "), list_usage_str);
                return 0;
        }
 
@@ -101,20 +103,20 @@ static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
                else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
                        fstrcpy( ntgroup, get_string_param( argv[i] ) );
                        if ( !ntgroup[0] ) {
-                               d_fprintf(stderr, "must supply a name\n");
+                               d_fprintf(stderr, _("must supply a name\n"));
                                return -1;
                        }
                }
                else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
                        fstrcpy( sid_string, get_string_param( argv[i] ) );
                        if ( !sid_string[0] ) {
-                               d_fprintf(stderr, "must supply a SID\n");
+                               d_fprintf(stderr, _("must supply a SID\n"));
                                return -1;
                        }
                }
                else {
-                       d_fprintf(stderr, "Bad option: %s\n", argv[i]);
-                       d_printf("Usage:\n%s\n", list_usage_str);
+                       d_fprintf(stderr, _("Bad option: %s\n"), argv[i]);
+                       d_printf("%s\n%s\n", _("Usage:"), list_usage_str);
                        return -1;
                }
        }
@@ -133,7 +135,9 @@ static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
 
                /* Get the current mapping from the database */
                if(!pdb_getgrsid(&map, sid)) {
-                       d_fprintf(stderr, "Failure to local group SID in the database\n");
+                       d_fprintf(stderr,
+                                 _("Failure to local group SID in the "
+                                   "database\n"));
                        return -1;
                }
 
@@ -174,10 +178,12 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
        GROUP_MAP map;
 
        const char *name_type;
-       const char add_usage_str[] = "net groupmap add {rid=<int>|sid=<string>}"
-                                    " unixgroup=<string> "
-                                    "[type=<domain|local|builtin>] "
-                                    "[ntgroup=<string>] [comment=<string>]";
+       const char add_usage_str[] = N_("net groupmap add "
+                                       "{rid=<int>|sid=<string>}"
+                                       " unixgroup=<string> "
+                                       "[type=<domain|local|builtin>] "
+                                       "[ntgroup=<string>] "
+                                       "[comment=<string>]");
 
        ZERO_STRUCT(map);
 
@@ -186,7 +192,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
        name_type = "domain group";
 
        if (c->display_usage) {
-               d_printf("Usage\n%s\n", add_usage_str);
+               d_printf("%s\n%s\n", _("Usage:\n"), add_usage_str);
                return 0;
        }
 
@@ -194,36 +200,39 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
        for ( i=0; i<argc; i++ ) {
                if ( !StrnCaseCmp(argv[i], "rid", strlen("rid")) ) {
                        rid = get_int_param(argv[i]);
-                       if ( rid < DOMAIN_GROUP_RID_ADMINS ) {
-                               d_fprintf(stderr, "RID must be greater than %d\n", (uint32)DOMAIN_GROUP_RID_ADMINS-1);
+                       if ( rid < DOMAIN_RID_ADMINS ) {
+                               d_fprintf(stderr,
+                                         _("RID must be greater than %d\n"),
+                                         (uint32)DOMAIN_RID_ADMINS-1);
                                return -1;
                        }
                }
                else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
                        fstrcpy( unixgrp, get_string_param( argv[i] ) );
                        if ( !unixgrp[0] ) {
-                               d_fprintf(stderr, "must supply a name\n");
+                               d_fprintf(stderr,_( "must supply a name\n"));
                                return -1;
                        }
                }
                else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
                        fstrcpy( ntgroup, get_string_param( argv[i] ) );
                        if ( !ntgroup[0] ) {
-                               d_fprintf(stderr, "must supply a name\n");
+                               d_fprintf(stderr, _("must supply a name\n"));
                                return -1;
                        }
                }
                else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
                        fstrcpy( string_sid, get_string_param( argv[i] ) );
                        if ( !string_sid[0] ) {
-                               d_fprintf(stderr, "must supply a SID\n");
+                               d_fprintf(stderr, _("must supply a SID\n"));
                                return -1;
                        }
                }
                else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
                        fstrcpy( ntcomment, get_string_param( argv[i] ) );
                        if ( !ntcomment[0] ) {
-                               d_fprintf(stderr, "must supply a comment string\n");
+                               d_fprintf(stderr,
+                                         _("must supply a comment string\n"));
                                return -1;
                        }
                }
@@ -246,50 +255,51 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
                                        name_type = "alias (local) group";
                                        break;
                                default:
-                                       d_fprintf(stderr, "unknown group type %s\n", type);
+                                       d_fprintf(stderr,
+                                                 _("unknown group type %s\n"),
+                                                 type);
                                        return -1;
                        }
                }
                else {
-                       d_fprintf(stderr, "Bad option: %s\n", argv[i]);
+                       d_fprintf(stderr, _("Bad option: %s\n"), argv[i]);
                        return -1;
                }
        }
 
        if ( !unixgrp[0] ) {
-               d_printf("Usage:\n%s\n", add_usage_str);
+               d_printf("%s\n%s\n", _("Usage:\n"), add_usage_str);
                return -1;
        }
 
        if ( (gid = nametogid(unixgrp)) == (gid_t)-1 ) {
-               d_fprintf(stderr, "Can't lookup UNIX group %s\n", unixgrp);
+               d_fprintf(stderr, _("Can't lookup UNIX group %s\n"), unixgrp);
                return -1;
        }
 
        {
                if (pdb_getgrgid(&map, gid)) {
-                       d_printf("Unix group %s already mapped to SID %s\n",
+                       d_printf(_("Unix group %s already mapped to SID %s\n"),
                                 unixgrp, sid_string_tos(&map.sid));
                        return -1;
                }
        }
 
        if ( (rid == 0) && (string_sid[0] == '\0') ) {
-               d_printf("No rid or sid specified, choosing a RID\n");
-               if (pdb_rid_algorithm()) {
-                       rid = algorithmic_pdb_gid_to_group_rid(gid);
-               } else {
+               d_printf(_("No rid or sid specified, choosing a RID\n"));
+               if (pdb_capabilities() & PDB_CAP_STORE_RIDS) {
                        if (!pdb_new_rid(&rid)) {
-                               d_printf("Could not get new RID\n");
+                               d_printf(_("Could not get new RID\n"));
                        }
+               } else {
+                       rid = algorithmic_pdb_gid_to_group_rid(gid);
                }
-               d_printf("Got RID %d\n", rid);
+               d_printf(_("Got RID %d\n"), rid);
        }
 
        /* append the rid to our own domain/machine SID if we don't have a full SID */
        if ( !string_sid[0] ) {
-               sid_copy(&sid, get_global_sam_sid());
-               sid_append_rid(&sid, rid);
+               sid_compose(&sid, get_global_sam_sid(), rid);
                sid_to_fstring(string_sid, &sid);
        }
 
@@ -314,11 +324,11 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
                fstrcpy( ntgroup, unixgrp );
 
        if (!NT_STATUS_IS_OK(add_initial_entry(gid, string_sid, sid_type, ntgroup, ntcomment))) {
-               d_fprintf(stderr, "adding entry for group %s failed!\n", ntgroup);
+               d_fprintf(stderr, _("adding entry for group %s failed!\n"), ntgroup);
                return -1;
        }
 
-       d_printf("Successfully added group %s to the mapping db as a %s\n",
+       d_printf(_("Successfully added group %s to the mapping db as a %s\n"),
                 ntgroup, name_type);
        return 0;
 }
@@ -335,14 +345,14 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
        enum lsa_SidType sid_type = SID_NAME_UNKNOWN;
        int i;
        gid_t gid;
-       const char modify_usage_str[] = "net groupmap modify "
-                                       "{ntgroup=<string>|sid=<SID>} "
-                                       "[comment=<string>] "
-                                       "[unixgroup=<string>] "
-                                       "[type=<domain|local>]";
+       const char modify_usage_str[] = N_("net groupmap modify "
+                                          "{ntgroup=<string>|sid=<SID>} "
+                                          "[comment=<string>] "
+                                          "[unixgroup=<string>] "
+                                          "[type=<domain|local>]");
 
        if (c->display_usage) {
-               d_printf("Usage:\n%s\n", modify_usage_str);
+               d_printf("%s\n%s\n", _("Usage:\n"), modify_usage_str);
                return 0;
        }
 
@@ -351,28 +361,30 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
                if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
                        fstrcpy( ntgroup, get_string_param( argv[i] ) );
                        if ( !ntgroup[0] ) {
-                               d_fprintf(stderr, "must supply a name\n");
+                               d_fprintf(stderr, _("must supply a name\n"));
                                return -1;
                        }
                }
                else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
                        fstrcpy( sid_string, get_string_param( argv[i] ) );
                        if ( !sid_string[0] ) {
-                               d_fprintf(stderr, "must supply a name\n");
+                               d_fprintf(stderr, _("must supply a name\n"));
                                return -1;
                        }
                }
                else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
                        fstrcpy( ntcomment, get_string_param( argv[i] ) );
                        if ( !ntcomment[0] ) {
-                               d_fprintf(stderr, "must supply a comment string\n");
+                               d_fprintf(stderr,
+                                         _("must supply a comment string\n"));
                                return -1;
                        }
                }
                else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
                        fstrcpy( unixgrp, get_string_param( argv[i] ) );
                        if ( !unixgrp[0] ) {
-                               d_fprintf(stderr, "must supply a group name\n");
+                               d_fprintf(stderr,
+                                         _("must supply a group name\n"));
                                return -1;
                        }
                }
@@ -390,13 +402,13 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
                        }
                }
                else {
-                       d_fprintf(stderr, "Bad option: %s\n", argv[i]);
+                       d_fprintf(stderr, _("Bad option: %s\n"), argv[i]);
                        return -1;
                }
        }
 
        if ( !ntgroup[0] && !sid_string[0] ) {
-               d_printf("Usage:\n%s\n", modify_usage_str);
+               d_printf("%s\n%s\n", _("Usage:\n"), modify_usage_str);
                return -1;
        }
 
@@ -417,7 +429,8 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
 
        /* Get the current mapping from the database */
        if(!pdb_getgrsid(&map, sid)) {
-               d_fprintf(stderr, "Failure to local group SID in the database\n");
+               d_fprintf(stderr,
+                        _("Failed to find local group SID in the database\n"));
                return -1;
        }
 
@@ -426,12 +439,14 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
         * We disallow changing Builtin groups !!! (SID problem)
         */
        if (sid_type == SID_NAME_UNKNOWN) {
-               d_fprintf(stderr, "Can't map to an unknown group type.\n");
+               d_fprintf(stderr, _("Can't map to an unknown group type.\n"));
                return -1;
         }
 
        if (map.sid_name_use == SID_NAME_WKN_GRP) {
-               d_fprintf(stderr, "You can only change between domain and local groups.\n");
+               d_fprintf(stderr,
+                         _("You can only change between domain and local "
+                           "groups.\n"));
                return -1;
        }
 
@@ -447,7 +462,8 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
        if ( unixgrp[0] ) {
                gid = nametogid( unixgrp );
                if ( gid == -1 ) {
-                       d_fprintf(stderr, "Unable to lookup UNIX group %s.  Make sure the group exists.\n",
+                       d_fprintf(stderr, _("Unable to lookup UNIX group %s.  "
+                                           "Make sure the group exists.\n"),
                                unixgrp);
                        return -1;
                }
@@ -456,11 +472,11 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
        }
 
        if ( !NT_STATUS_IS_OK(pdb_update_group_mapping_entry(&map)) ) {
-               d_fprintf(stderr, "Could not update group database\n");
+               d_fprintf(stderr, _("Could not update group database\n"));
                return -1;
        }
 
-       d_printf("Updated mapping entry for %s\n", map.nt_name);
+       d_printf(_("Updated mapping entry for %s\n"), map.nt_name);
 
        return 0;
 }
@@ -471,11 +487,11 @@ static int net_groupmap_delete(struct net_context *c, int argc, const char **arg
        fstring ntgroup = "";
        fstring sid_string = "";
        int i;
-       const char delete_usage_str[] = "net groupmap delete "
-                                       "{ntgroup=<string>|sid=<SID>}";
+       const char delete_usage_str[] = N_("net groupmap delete "
+                                          "{ntgroup=<string>|sid=<SID>}");
 
        if (c->display_usage) {
-               d_printf("Usage:\n%s\n", delete_usage_str);
+               d_printf("%s\n%s\n", _("Usage:\n"), delete_usage_str);
                return 0;
        }
 
@@ -484,25 +500,25 @@ static int net_groupmap_delete(struct net_context *c, int argc, const char **arg
                if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
                        fstrcpy( ntgroup, get_string_param( argv[i] ) );
                        if ( !ntgroup[0] ) {
-                               d_fprintf(stderr, "must supply a name\n");
+                               d_fprintf(stderr, _("must supply a name\n"));
                                return -1;
                        }
                }
                else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
                        fstrcpy( sid_string, get_string_param( argv[i] ) );
                        if ( !sid_string[0] ) {
-                               d_fprintf(stderr, "must supply a SID\n");
+                               d_fprintf(stderr, _("must supply a SID\n"));
                                return -1;
                        }
                }
                else {
-                       d_fprintf(stderr, "Bad option: %s\n", argv[i]);
+                       d_fprintf(stderr, _("Bad option: %s\n"), argv[i]);
                        return -1;
                }
        }
 
        if ( !ntgroup[0] && !sid_string[0]) {
-               d_printf("Usage:\n%s\n", delete_usage_str);
+               d_printf("%s\n%s\n", _("Usage:\n"), delete_usage_str);
                return -1;
        }
 
@@ -512,16 +528,19 @@ static int net_groupmap_delete(struct net_context *c, int argc, const char **arg
                fstrcpy( ntgroup, sid_string );
 
        if ( !get_sid_from_input(&sid, ntgroup) ) {
-               d_fprintf(stderr, "Unable to resolve group %s to a SID\n", ntgroup);
+               d_fprintf(stderr, _("Unable to resolve group %s to a SID\n"),
+                         ntgroup);
                return -1;
        }
 
        if ( !NT_STATUS_IS_OK(pdb_delete_group_mapping_entry(sid)) ) {
-               d_fprintf(stderr, "Failed to removing group %s from the mapping db!\n", ntgroup);
+               d_fprintf(stderr,
+                         _("Failed to remove group %s from the mapping db!\n"),
+                         ntgroup);
                return -1;
        }
 
-       d_printf("Sucessfully removed %s from the mapping db\n", ntgroup);
+       d_printf(_("Sucessfully removed %s from the mapping db\n"), ntgroup);
 
        return 0;
 }
@@ -534,13 +553,15 @@ static int net_groupmap_set(struct net_context *c, int argc, const char **argv)
        bool have_map = false;
 
        if ((argc < 1) || (argc > 2) || c->display_usage) {
-               d_printf("Usage: net groupmap set \"NT Group\" "
-                        "[\"unix group\"] [-C \"comment\"] [-L] [-D]\n");
+               d_printf("%s\n%s",
+                        _("Usage:"),
+                        _(" net groupmap set \"NT Group\" "
+                          "[\"unix group\"] [-C \"comment\"] [-L] [-D]\n"));
                return -1;
        }
 
        if ( c->opt_localgroup && c->opt_domaingroup ) {
-               d_printf("Can only specify -L or -D, not both\n");
+               d_printf(_("Can only specify -L or -D, not both\n"));
                return -1;
        }
 
@@ -550,7 +571,8 @@ static int net_groupmap_set(struct net_context *c, int argc, const char **argv)
                grp = getgrnam(argv[1]);
 
                if (grp == NULL) {
-                       d_fprintf(stderr, "Could not find unix group %s\n", argv[1]);
+                       d_fprintf(stderr, _("Could not find unix group %s\n"),
+                                 argv[1]);
                        return -1;
                }
        }
@@ -569,34 +591,36 @@ static int net_groupmap_set(struct net_context *c, int argc, const char **argv)
                /* Ok, add it */
 
                if (grp == NULL) {
-                       d_fprintf(stderr, "Could not find group mapping for %s\n",
-                                ntgroup);
+                       d_fprintf(stderr,
+                                 _("Could not find group mapping for %s\n"),
+                                 ntgroup);
                        return -1;
                }
 
                map.gid = grp->gr_gid;
 
                if (c->opt_rid == 0) {
-                       if ( pdb_rid_algorithm() )
-                               c->opt_rid = algorithmic_pdb_gid_to_group_rid(map.gid);
-                       else {
+                       if ( pdb_capabilities() & PDB_CAP_STORE_RIDS ) {
                                if ( !pdb_new_rid((uint32*)&c->opt_rid) ) {
-                                       d_fprintf( stderr, "Could not allocate new RID\n");
+                                       d_fprintf( stderr,
+                                           _("Could not allocate new RID\n"));
                                        return -1;
                                }
+                       } else {
+                               c->opt_rid = algorithmic_pdb_gid_to_group_rid(map.gid);
                        }
                }
 
-               sid_copy(&map.sid, get_global_sam_sid());
-               sid_append_rid(&map.sid, c->opt_rid);
+               sid_compose(&map.sid, get_global_sam_sid(), c->opt_rid);
 
                map.sid_name_use = SID_NAME_DOM_GRP;
                fstrcpy(map.nt_name, ntgroup);
                fstrcpy(map.comment, "");
 
                if (!NT_STATUS_IS_OK(pdb_add_group_mapping_entry(&map))) {
-                       d_fprintf(stderr, "Could not add mapping entry for %s\n",
-                                ntgroup);
+                       d_fprintf(stderr,
+                                 _("Could not add mapping entry for %s\n"),
+                                 ntgroup);
                        return -1;
                }
        }
@@ -605,8 +629,10 @@ static int net_groupmap_set(struct net_context *c, int argc, const char **argv)
 
        if ( c->opt_localgroup || c->opt_domaingroup ) {
                if (map.sid_name_use == SID_NAME_WKN_GRP) {
-                       d_fprintf(stderr, "Can't change type of the BUILTIN group %s\n",
-                                map.nt_name);
+                       d_fprintf(stderr,
+                                 _("Can't change type of the BUILTIN "
+                                   "group %s\n"),
+                                 map.nt_name);
                        return -1;
                }
        }
@@ -619,17 +645,20 @@ static int net_groupmap_set(struct net_context *c, int argc, const char **argv)
 
        /* The case (opt_domaingroup && opt_localgroup) was tested for above */
 
-       if (strlen(c->opt_comment) > 0)
+       if ((c->opt_comment != NULL) && (strlen(c->opt_comment) > 0)) {
                fstrcpy(map.comment, c->opt_comment);
+       }
 
-       if (strlen(c->opt_newntname) > 0)
+       if ((c->opt_newntname != NULL) && (strlen(c->opt_newntname) > 0)) {
                fstrcpy(map.nt_name, c->opt_newntname);
+       }
 
        if (grp != NULL)
                map.gid = grp->gr_gid;
 
        if (!NT_STATUS_IS_OK(pdb_update_group_mapping_entry(&map))) {
-               d_fprintf(stderr, "Could not update group mapping for %s\n", ntgroup);
+               d_fprintf(stderr, _("Could not update group mapping for %s\n"),
+                         ntgroup);
                return -1;
        }
 
@@ -642,25 +671,27 @@ static int net_groupmap_cleanup(struct net_context *c, int argc, const char **ar
        size_t i, entries;
 
        if (c->display_usage) {
-               d_printf("Usage:\n"
-                        "net groupmap cleanup\n"
-                        "    Delete all group mappings\n");
+               d_printf(  "%s\n"
+                          "net groupmap cleanup\n"
+                          "    %s\n",
+                        _("Usage:"),
+                        _("Delete all group mappings"));
                return 0;
        }
 
        if (!pdb_enum_group_mapping(NULL, SID_NAME_UNKNOWN, &map, &entries,
                                    ENUM_ALL_MAPPED)) {
-               d_fprintf(stderr, "Could not list group mappings\n");
+               d_fprintf(stderr, _("Could not list group mappings\n"));
                return -1;
        }
 
        for (i=0; i<entries; i++) {
 
                if (map[i].gid == -1)
-                       printf("Group %s is not mapped\n", map[i].nt_name);
+                       printf(_("Group %s is not mapped\n"), map[i].nt_name);
 
                if (!sid_check_is_in_our_domain(&map[i].sid)) {
-                       printf("Deleting mapping for NT Group %s, sid %s\n",
+                       printf(_("Deleting mapping for NT Group %s, sid %s\n"),
                               map[i].nt_name,
                               sid_string_tos(&map[i].sid));
                        pdb_delete_group_mapping_entry(map[i].sid);
@@ -680,12 +711,14 @@ static int net_groupmap_addmem(struct net_context *c, int argc, const char **arg
             c->display_usage ||
             !string_to_sid(&alias, argv[0]) ||
             !string_to_sid(&member, argv[1]) ) {
-               d_printf("Usage: net groupmap addmem alias-sid member-sid\n");
+               d_printf("%s\n%s",
+                        _("Usage:"),
+                        _("net groupmap addmem alias-sid member-sid\n"));
                return -1;
        }
 
        if (!NT_STATUS_IS_OK(pdb_add_aliasmem(&alias, &member))) {
-               d_fprintf(stderr, "Could not add sid %s to alias %s\n",
+               d_fprintf(stderr, _("Could not add sid %s to alias %s\n"),
                         argv[1], argv[0]);
                return -1;
        }
@@ -701,12 +734,14 @@ static int net_groupmap_delmem(struct net_context *c, int argc, const char **arg
             c->display_usage ||
             !string_to_sid(&alias, argv[0]) ||
             !string_to_sid(&member, argv[1]) ) {
-               d_printf("Usage: net groupmap delmem alias-sid member-sid\n");
+               d_printf("%s\n%s",
+                        _("Usage:"),
+                        _("net groupmap delmem alias-sid member-sid\n"));
                return -1;
        }
 
        if (!NT_STATUS_IS_OK(pdb_del_aliasmem(&alias, &member))) {
-               d_fprintf(stderr, "Could not delete sid %s from alias %s\n",
+               d_fprintf(stderr, _("Could not delete sid %s from alias %s\n"),
                         argv[1], argv[0]);
                return -1;
        }
@@ -723,15 +758,19 @@ static int net_groupmap_listmem(struct net_context *c, int argc, const char **ar
        if ( (argc != 1) ||
             c->display_usage ||
             !string_to_sid(&alias, argv[0]) ) {
-               d_printf("Usage: net groupmap listmem alias-sid\n");
+               d_printf("%s\n%s",
+                        _("Usage:"),
+                        _("net groupmap listmem alias-sid\n"));
                return -1;
        }
 
        members = NULL;
        num = 0;
 
-       if (!NT_STATUS_IS_OK(pdb_enum_aliasmem(&alias, &members, &num))) {
-               d_fprintf(stderr, "Could not list members for sid %s\n", argv[0]);
+       if (!NT_STATUS_IS_OK(pdb_enum_aliasmem(&alias, talloc_tos(),
+                                              &members, &num))) {
+               d_fprintf(stderr, _("Could not list members for sid %s\n"),
+                         argv[0]);
                return -1;
        }
 
@@ -757,15 +796,14 @@ static bool print_alias_memberships(TALLOC_CTX *mem_ctx,
        if (!NT_STATUS_IS_OK(pdb_enum_alias_memberships(
                                     mem_ctx, domain_sid, member, 1,
                                     &alias_rids, &num_alias_rids))) {
-               d_fprintf(stderr, "Could not list memberships for sid %s\n",
+               d_fprintf(stderr, _("Could not list memberships for sid %s\n"),
                         sid_string_tos(member));
                return false;
        }
 
        for (i = 0; i < num_alias_rids; i++) {
                DOM_SID alias;
-               sid_copy(&alias, domain_sid);
-               sid_append_rid(&alias, alias_rids[i]);
+               sid_compose(&alias, domain_sid, alias_rids[i]);
                printf("%s\n", sid_string_tos(&alias));
        }
 
@@ -775,30 +813,31 @@ static bool print_alias_memberships(TALLOC_CTX *mem_ctx,
 static int net_groupmap_memberships(struct net_context *c, int argc, const char **argv)
 {
        TALLOC_CTX *mem_ctx;
-       DOM_SID *domain_sid, *builtin_sid, member;
+       DOM_SID *domain_sid, member;
 
        if ( (argc != 1) ||
             c->display_usage ||
             !string_to_sid(&member, argv[0]) ) {
-               d_printf("Usage: net groupmap memberof sid\n");
+               d_printf("%s\n%s",
+                        _("Usage:"),
+                        _("net groupmap memberof sid\n"));
                return -1;
        }
 
        mem_ctx = talloc_init("net_groupmap_memberships");
        if (mem_ctx == NULL) {
-               d_fprintf(stderr, "talloc_init failed\n");
+               d_fprintf(stderr, _("talloc_init failed\n"));
                return -1;
        }
 
        domain_sid = get_global_sam_sid();
-       builtin_sid = string_sid_talloc(mem_ctx, "S-1-5-32");
-       if ((domain_sid == NULL) || (builtin_sid == NULL)) {
-               d_fprintf(stderr, "Could not get domain sid\n");
+       if (domain_sid == NULL) {
+               d_fprintf(stderr, _("Could not get domain sid\n"));
                return -1;
        }
 
        if (!print_alias_memberships(mem_ctx, domain_sid, &member) ||
-           !print_alias_memberships(mem_ctx, builtin_sid, &member))
+           !print_alias_memberships(mem_ctx, &global_sid_Builtin, &member))
                return -1;
 
        talloc_destroy(mem_ctx);
@@ -816,91 +855,85 @@ int net_groupmap(struct net_context *c, int argc, const char **argv)
                        "add",
                        net_groupmap_add,
                        NET_TRANSPORT_LOCAL,
-                       "Create a new group mapping",
-                       "net groupmap add\n"
-                       "    Create a new group mapping"
+                       N_("Create a new group mapping"),
+                       N_("net groupmap add\n"
+                          "    Create a new group mapping")
                },
                {
                        "modify",
                        net_groupmap_modify,
                        NET_TRANSPORT_LOCAL,
-                       "Update a group mapping",
-                       "net groupmap modify\n"
-                       "    Modify an existing group mapping"
+                       N_("Update a group mapping"),
+                       N_("net groupmap modify\n"
+                          "    Modify an existing group mapping")
                },
                {
                        "delete",
                        net_groupmap_delete,
                        NET_TRANSPORT_LOCAL,
-                       "Remove a group mapping",
-                       "net groupmap delete\n"
-                       "    Remove a group mapping"
+                       N_("Remove a group mapping"),
+                       N_("net groupmap delete\n"
+                          "    Remove a group mapping")
                },
                {
                        "set",
                        net_groupmap_set,
                        NET_TRANSPORT_LOCAL,
-                       "Set group mapping",
-                       "net groupmap set\n"
-                       "    Set a group mapping"
+                       N_("Set group mapping"),
+                       N_("net groupmap set\n"
+                          "    Set a group mapping")
                },
                {
                        "cleanup",
                        net_groupmap_cleanup,
                        NET_TRANSPORT_LOCAL,
-                       "Remove foreign group mapping entries",
-                       "net groupmap cleanup\n"
-                       "    Remove foreign group mapping entries"
+                       N_("Remove foreign group mapping entries"),
+                       N_("net groupmap cleanup\n"
+                          "    Remove foreign group mapping entries")
                },
                {
                        "addmem",
                        net_groupmap_addmem,
                        NET_TRANSPORT_LOCAL,
-                       "Add a foreign alias member",
-                       "net groupmap addmem\n"
-                       "    Add a foreign alias member"
+                       N_("Add a foreign alias member"),
+                       N_("net groupmap addmem\n"
+                          "    Add a foreign alias member")
                },
                {
                        "delmem",
                        net_groupmap_delmem,
                        NET_TRANSPORT_LOCAL,
-                       "Delete foreign alias member",
-                       "net groupmap delmem\n"
-                       "    Delete foreign alias member"
+                       N_("Delete foreign alias member"),
+                       N_("net groupmap delmem\n"
+                          "    Delete foreign alias member")
                },
                {
                        "listmem",
                        net_groupmap_listmem,
                        NET_TRANSPORT_LOCAL,
-                       "List foreign group members",
-                       "net groupmap listmem\n"
-                       "    List foreign alias members"
+                       N_("List foreign group members"),
+                       N_("net groupmap listmem\n"
+                          "    List foreign alias members")
                },
                {
                        "memberships",
                        net_groupmap_memberships,
                        NET_TRANSPORT_LOCAL,
-                       "List foreign group memberships",
-                       "net groupmap memberships\n"
-                       "    List foreign group memberships"
+                       N_("List foreign group memberships"),
+                       N_("net groupmap memberships\n"
+                          "    List foreign group memberships")
                },
                {
                        "list",
                        net_groupmap_list,
                        NET_TRANSPORT_LOCAL,
-                       "List current group map",
-                       "net groupmap list\n"
-                       "    List current group map"
+                       N_("List current group map"),
+                       N_("net groupmap list\n"
+                          "    List current group map")
                },
                {NULL, NULL, 0, NULL, NULL}
        };
 
-       /* we shouldn't have silly checks like this */
-       if (getuid() != 0) {
-               d_fprintf(stderr, "You must be root to edit group mappings.\n");
-               return -1;
-       }
-
        return net_run_function(c,argc, argv, "net groupmap", func);
 }