static int net_groupmap_cleanup(struct net_context *c, int argc, const char **argv) { GROUP_MAP **maps = NULL; size_t i, entries; if (c->display_usage) { 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, &maps, &entries, ENUM_ALL_MAPPED)) { d_fprintf(stderr, _("Could not list group mappings\n")); return -1; } for (i=0; i<entries; i++) { if (maps[i]->gid == -1) printf(_("Group %s is not mapped\n"), maps[i]->nt_name); if (!sid_check_is_in_our_domain(&maps[i]->sid)) { printf(_("Deleting mapping for NT Group %s, sid %s\n"), maps[i]->nt_name, sid_string_tos(&maps[i]->sid)); pdb_delete_group_mapping_entry(maps[i]->sid); } } TALLOC_FREE(maps); return 0; }
static int net_groupmap_delete(struct net_context *c, int argc, const char **argv) { struct dom_sid sid; fstring ntgroup = ""; fstring sid_string = ""; int i; const char delete_usage_str[] = N_("net groupmap delete " "{ntgroup=<string>|sid=<SID>}"); if (c->display_usage) { d_printf("%s\n%s\n", _("Usage:\n"), delete_usage_str); return 0; } /* get the options */ for ( i=0; i<argc; i++ ) { if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) { fstrcpy( ntgroup, get_string_param( argv[i] ) ); if ( !ntgroup[0] ) { d_fprintf(stderr, _("must supply a name\n")); return -1; } } else if ( !strncasecmp_m(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")); return -1; } } else { d_fprintf(stderr, _("Bad option: %s\n"), argv[i]); return -1; } } if ( !ntgroup[0] && !sid_string[0]) { d_printf("%s\n%s\n", _("Usage:\n"), delete_usage_str); return -1; } /* give preference to the SID if we have that */ if ( sid_string[0] ) strlcpy(ntgroup, sid_string, sizeof(ntgroup)); if ( !get_sid_from_input(&sid, 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 remove group %s from the mapping db!\n"), ntgroup); return -1; } d_printf(_("Sucessfully removed %s from the mapping db\n"), ntgroup); return 0; }
NTSTATUS pdb_default_delete_alias(struct pdb_methods *methods, const DOM_SID *sid) { return pdb_delete_group_mapping_entry(*sid); }