diff options
-rw-r--r-- | source3/utils/net_sam.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index 6321fab54f..fc7dfea02c 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -533,10 +533,24 @@ static int net_sam_addmem(int argc, const char **argv) return -1; } + /* check to see if the member to be added is a name or a SID */ + if (!lookup_name(tmp_talloc_ctx(), argv[1], LOOKUP_NAME_ISOLATED, - &memberdomain, &membername, &member, &membertype)) { - d_fprintf(stderr, "Could not find member %s\n", argv[1]); - return -1; + &memberdomain, &membername, &member, &membertype)) + { + /* try it as a SID */ + + if ( !string_to_sid( &member, argv[1] ) ) { + d_fprintf(stderr, "Could not find member %s\n", argv[1]); + return -1; + } + + if ( !lookup_sid(tmp_talloc_ctx(), &member, &memberdomain, + &membername, &membertype) ) + { + d_fprintf(stderr, "Could not resolve SID %s\n", argv[1]); + return -1; + } } if ((grouptype == SID_NAME_ALIAS) || (grouptype == SID_NAME_WKN_GRP)) { @@ -562,8 +576,8 @@ static int net_sam_addmem(int argc, const char **argv) return -1; } - d_printf("Added %s\\%s to %s\\%s\n", - memberdomain, membername, groupdomain, groupname); + d_printf("Added %s\\%s to %s\\%s\n", memberdomain, membername, + groupdomain, groupname); return 0; } |