summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2006-03-24 23:54:08 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:44 -0500
commitefd32bf37183c5c797cec0da37cd347a4a1bfbb2 (patch)
tree23408c42019d57d19d5bbe09d1e8b5826d5a1c8b
parent190554b770b9f21c1641574c29acaa4fbea90f48 (diff)
downloadsamba-efd32bf37183c5c797cec0da37cd347a4a1bfbb2.tar.gz
samba-efd32bf37183c5c797cec0da37cd347a4a1bfbb2.tar.bz2
samba-efd32bf37183c5c797cec0da37cd347a4a1bfbb2.zip
r14699: allow 'net sam addmem' to accept a SID for the member
(This used to be commit 08d201806f53f51fbed4a02a54cb0656f8287b12)
-rw-r--r--source3/utils/net_sam.c24
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;
}