summaryrefslogtreecommitdiff
path: root/source3/passdb/pdb_tdb.c
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2003-07-20 21:43:41 +0000
committerRafal Szczesniak <mimir@samba.org>2003-07-20 21:43:41 +0000
commitb3064ac5d64f54562e4f2d7d1b021374def1352d (patch)
treebf8e2e90cdf9f95736663cd1746cd9a1a643c45c /source3/passdb/pdb_tdb.c
parentbbd4c98b06a3a60b93f43f9dc2a824d76138a300 (diff)
downloadsamba-b3064ac5d64f54562e4f2d7d1b021374def1352d.tar.gz
samba-b3064ac5d64f54562e4f2d7d1b021374def1352d.tar.bz2
samba-b3064ac5d64f54562e4f2d7d1b021374def1352d.zip
This creates passdb backend files automatically when adding first account.
An extra message notifying that needed file didn't exist is displayed. There's still a little catch with tdb backend, but it's better than it was, from end-user's point of view. This fixes #198 rafal (This used to be commit b0be700605c289ce8e9dd3abe49d78ac77256911)
Diffstat (limited to 'source3/passdb/pdb_tdb.c')
-rw-r--r--source3/passdb/pdb_tdb.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index 1078a5bd26..051a699357 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -180,6 +180,24 @@ static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT
/* open the accounts TDB */
if (!(pwd_tdb = tdb_open_log(tdb_state->tdbsam_location, 0, TDB_DEFAULT, O_RDONLY, 0600))) {
+
+ if (errno == ENOENT) {
+ /*
+ * TDB file doesn't exist, so try to create new one. This is useful to avoid
+ * confusing error msg when adding user account first time
+ */
+ if (!(pwd_tdb = tdb_open_log(tdb_state->tdbsam_location, 0, TDB_DEFAULT, O_CREAT, 0600))) {
+ DEBUG(0, ("pdb_getsampwnam: TDB passwd (%s) did not exist. File successfully created.\n",
+ tdb_state->tdbsam_location));
+ } else {
+ DEBUG(0, ("pdb_getsampwnam: TDB passwd (%s) does not exist. Couldn't create new one. Error was: %s\n",
+ tdb_state->tdbsam_location, strerror(errno)));
+ }
+
+ /* requested user isn't there anyway */
+ nt_status = NT_STATUS_NO_SUCH_USER;
+ return nt_status;
+ }
DEBUG(0, ("pdb_getsampwnam: Unable to open TDB passwd (%s)!\n", tdb_state->tdbsam_location));
return nt_status;
}
@@ -423,7 +441,7 @@ done:
/***************************************************************************
Allocates a new RID and returns it to the caller as a domain sid
- NOTE: Use carefullt, do not waste RIDs they are a limited resource!
+ NOTE: Use carefully, do not waste RIDs they are a limited resource!
- SSS
***************************************************************************/