diff options
author | Simo Sorce <idra@samba.org> | 2004-07-13 12:39:38 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:52:12 -0500 |
commit | 75900ae52615f899c3da56341446c5fedfe1c58f (patch) | |
tree | b157ebf11d06adaaef112e1c61ebba07ed4d1f04 /source3/utils | |
parent | f9e72f1a419b011b9660474552adee47b51a765e (diff) | |
download | samba-75900ae52615f899c3da56341446c5fedfe1c58f.tar.gz samba-75900ae52615f899c3da56341446c5fedfe1c58f.tar.bz2 samba-75900ae52615f899c3da56341446c5fedfe1c58f.zip |
r1478: Useful patch from Tom Alsberg <alsbergt@cs.huji.ac.il>, to export a single user from a backend.
(This used to be commit 083740e74e0790f863c065a20e28f553fdc7d5bd)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/pdbedit.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 06e9df22c2..16d0d40769 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -57,9 +57,12 @@ Add all currently available users to another db ********************************************************/ -static int export_database (struct pdb_context *in, struct pdb_context *out) { +static int export_database (struct pdb_context *in, struct pdb_context + *out, const char *username) { SAM_ACCOUNT *user = NULL; + DEBUG(3, ("called with username=\"%s\"\n", username)); + if (NT_STATUS_IS_ERR(in->pdb_setsampwent(in, 0))) { fprintf(stderr, "Can't sampwent!\n"); return 1; @@ -71,10 +74,17 @@ static int export_database (struct pdb_context *in, struct pdb_context *out) { } while (NT_STATUS_IS_OK(in->pdb_getsampwent(in, user))) { - out->pdb_add_sam_account(out, user); - if (!NT_STATUS_IS_OK(pdb_reset_sam(user))){ - fprintf(stderr, "Can't reset SAM_ACCOUNT!\n"); - return 1; + DEBUG(4, ("Processing account %s\n", + user->private.username)); + if (!username || + (strcmp(username, user->private.username) + == 0)) { + out->pdb_add_sam_account(out, user); + if (!NT_STATUS_IS_OK(pdb_reset_sam(user))) { + fprintf(stderr, + "Can't reset SAM_ACCOUNT!\n"); + return 1; + } } } @@ -764,7 +774,7 @@ int main (int argc, char **argv) /* import and export operations */ if (((checkparms & BIT_IMPORT) || (checkparms & BIT_EXPORT)) - && !(checkparms & ~(BIT_IMPORT +BIT_EXPORT))) { + && !(checkparms & ~(BIT_IMPORT +BIT_EXPORT +BIT_USER))) { if (backend_in) { if (!NT_STATUS_IS_OK(make_pdb_context_string(&bin, backend_in))) { fprintf(stderr, "Can't initialize passdb backend.\n"); @@ -782,9 +792,15 @@ int main (int argc, char **argv) bout = bdef; } if (transfer_groups) { - return export_groups(bin, bout); + if (!(checkparms & BIT_USER)) + return export_groups(bin, bout); } else { - return export_database(bin, bout); + if (checkparms & BIT_USER) + return export_database(bin, bout, + user_name); + else + return export_database(bin, bout, + NULL); } } |