summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1998-05-11 18:03:01 +0000
committerLuke Leighton <lkcl@samba.org>1998-05-11 18:03:01 +0000
commit9141acecdcebd9276107a500435e3d4545020056 (patch)
treef4cd71c6a289d6870946270363a36744fc72d4de /source3/passdb
parent05eb22f77c21f8027e64b0caddefa4d9f030f95f (diff)
downloadsamba-9141acecdcebd9276107a500435e3d4545020056.tar.gz
samba-9141acecdcebd9276107a500435e3d4545020056.tar.bz2
samba-9141acecdcebd9276107a500435e3d4545020056.zip
password back-end database support
ldap.c : - added getldap21pwent() function passdb.c : - getsam21pwent() no longer a stub: calls ldap21 or smb21 smbpass.c : - added getsmb21pwent() function (he he :-) lib/rpc/server/srv_samr.c : - removed "specific" calls to ldap functions; replaced with call to get_sampwd_entries instead (which is unfinished). - rewrote get_user_info_21 function to call getsam21pwrid. (This used to be commit c760ebbf127796427c4602aae61952df938c6def)
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/ldap.c31
-rw-r--r--source3/passdb/passdb.c13
-rw-r--r--source3/passdb/smbpass.c109
3 files changed, 140 insertions, 13 deletions
diff --git a/source3/passdb/ldap.c b/source3/passdb/ldap.c
index 8547cf45cf..7af8a1b9f1 100644
--- a/source3/passdb/ldap.c
+++ b/source3/passdb/ldap.c
@@ -496,12 +496,37 @@ void *startldappwent(BOOL update)
*************************************************************************/
struct smb_passwd *getldappwent(void *vp)
{
+ static struct smb_passwd user;
+ struct ldap_enum_info *ldap_vp = (struct ldap_enum_info *)vp;
+
+ ldap_vp->entry = ldap_next_entry(ldap_vp->ldap_struct, ldap_vp->entry);
+
+ if (ldap_vp->entry != NULL)
+ {
+ ldap_get_smb_passwd(ldap_vp->ldap_struct, ldap_vp->entry, &user);
+ return &user;
+ }
+ return NULL;
+}
+
+/*************************************************************************
+ Routine to return the next entry in the ldap passwd list.
+
+ do not call this function directly. use passdb.c instead.
+ *************************************************************************/
+struct sam_passwd *getldap21pwent(void *vp)
+{
+ static struct sam_passwd user;
struct ldap_enum_info *ldap_vp = (struct ldap_enum_info *)vp;
+
ldap_vp->entry = ldap_next_entry(ldap_vp->ldap_struct, ldap_vp->entry);
-/*
- make_ldap_sam_user_info_21(ldap_struct, entry, &(pw_buf[(*num_entries)]) );
-*/
+
+ if (ldap_vp->entry != NULL)
+ {
+ ldap_get_sam_passwd(ldap_vp->ldap_struct, ldap_vp->entry, &user);
+ return &user;
+ }
return NULL;
}
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 263bbe57cd..5fa354b637 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -87,16 +87,11 @@ struct smb_passwd *getsampwent(void *vp)
*************************************************************************/
struct sam_passwd *getsam21pwent(void *vp)
{
-#if 0
#ifdef USE_LDAP
return getldap21pwent(vp);
#else
return getsmb21pwent(vp);
#endif /* USE_LDAP */
-#else
- DEBUG(0,("getsam21pwent: under development\n"));
- return NULL;
-#endif
}
/*************************************************************************
@@ -144,9 +139,9 @@ BOOL add_sam21pwd_entry(struct sam_passwd *newpwd)
{
#if 0
#ifdef USE_LDAP
- return add_ldappwd_entry(newpwd);
+ return add_ldap21pwd_entry(newpwd);
#else
- return add_smbpwd_entry(newpwd);
+ return add_smb21pwd_entry(newpwd);
#endif /* USE_LDAP */
#else
DEBUG(0,("add_sam21pwd_entry() - under development\n"));
@@ -183,9 +178,9 @@ BOOL mod_sam21pwd_entry(struct sam_passwd* pwd, BOOL override)
{
#if 0
#ifdef USE_LDAP
- return mod_ldappwd_entry(pwd, override);
+ return mod_ldap21pwd_entry(pwd, override);
#else
- return mod_smbpwd_entry(pwd, override);
+ return mod_smb21pwd_entry(pwd, override);
#endif /* USE_LDAP */
#else
DEBUG(0,("mod_sam21pwd_entry() - under development\n"));
diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c
index 3f6ce8aaef..9c0b276074 100644
--- a/source3/passdb/smbpass.c
+++ b/source3/passdb/smbpass.c
@@ -20,6 +20,8 @@
#include "includes.h"
extern int DEBUGLEVEL;
+extern pstring samlogon_user;
+extern BOOL sam_logon_in_ssb;
static int gotalarm;
static char s_readbuf[16 * 1024];
@@ -154,7 +156,6 @@ void *startsmbpwent(BOOL update)
/***************************************************************
End enumeration of the smbpasswd list.
****************************************************************/
-
void endsmbpwent(void *vp)
{
FILE *fp = (FILE *)vp;
@@ -166,6 +167,112 @@ void endsmbpwent(void *vp)
/*************************************************************************
Routine to return the next entry in the smbpasswd list.
+ this function is a nice, messy combination of reading:
+ - the smbpasswd file
+ - the unix password database
+ - smb.conf options (not done at present).
+
+ do not call this function directly. use passdb.c instead.
+
+ *************************************************************************/
+struct sam_passwd *getsmb21pwent(void *vp)
+{
+ struct smb_passwd *pw_buf = getsmbpwent(vp);
+ static struct sam_passwd user;
+ struct passwd *pwfile;
+
+ static pstring full_name;
+ static pstring home_dir;
+ static pstring home_drive;
+ static pstring logon_script;
+ static pstring profile_path;
+ static pstring acct_desc;
+ static pstring workstations;
+
+ if (pw_buf == NULL) return NULL;
+
+ pwfile = getpwnam(pw_buf->smb_name);
+ if (pwfile == NULL) return NULL;
+
+ bzero(&user, sizeof(user));
+
+ pstrcpy(samlogon_user, pw_buf->smb_name);
+
+ if (samlogon_user[strlen(samlogon_user)-1] != '$')
+ {
+ /* XXXX hack to get standard_sub_basic() to use sam logon username */
+ /* possibly a better way would be to do a become_user() call */
+ sam_logon_in_ssb = True;
+
+ user.smb_userid = pw_buf->smb_userid;
+ user.smb_grpid = pwfile->pw_gid;
+
+ user.user_rid = uid_to_user_rid (user.smb_userid);
+ user.group_rid = gid_to_group_rid(user.smb_grpid );
+
+ pstrcpy(full_name , pwfile->pw_gecos );
+ pstrcpy(logon_script , lp_logon_script ());
+ pstrcpy(profile_path , lp_logon_path ());
+ pstrcpy(home_drive , lp_logon_drive ());
+ pstrcpy(home_dir , lp_logon_home ());
+ pstrcpy(acct_desc , "");
+ pstrcpy(workstations , lp_domain_workstations());
+
+ sam_logon_in_ssb = False;
+ }
+ else
+ {
+ user.smb_userid = pw_buf->smb_userid;
+ user.smb_grpid = pwfile->pw_gid;
+
+ user.user_rid = uid_to_user_rid (user.smb_userid);
+ user.group_rid = DOMAIN_GROUP_RID_USERS; /* lkclXXXX this is OBSERVED behaviour by NT PDCs, enforced here. */
+
+ pstrcpy(full_name , "");
+ pstrcpy(logon_script , "");
+ pstrcpy(profile_path , "");
+ pstrcpy(home_drive , "");
+ pstrcpy(home_dir , "");
+ pstrcpy(acct_desc , "");
+ pstrcpy(workstations , "");
+ }
+
+ user.logon_time = (time_t)-1;
+ user.logoff_time = (time_t)-1;
+ user.kickoff_time = (time_t)-1;
+ user.pass_last_set_time = pw_buf->pass_last_set_time;
+ user.pass_can_change_time = (time_t)-1;
+ user.pass_must_change_time = (time_t)-1;
+
+ user.smb_name = pw_buf->smb_name;
+ user.full_name = full_name;
+ user.home_dir = home_dir;
+ user.dir_drive = home_drive;
+ user.logon_script = logon_script;
+ user.profile_path = profile_path;
+ user.acct_desc = acct_desc;
+ user.workstations = workstations;
+
+ user.unknown_str = NULL; /* don't know, yet! */
+ user.munged_dial = NULL; /* "munged" dial-back telephone number */
+
+ user.smb_nt_passwd = pw_buf->smb_nt_passwd;
+ user.smb_passwd = pw_buf->smb_passwd;
+
+ user.acct_ctrl = pw_buf->acct_ctrl;
+
+ user.unknown_3 = 0xffffff; /* don't know */
+ user.logon_divs = 168; /* hours per week */
+ user.hours_len = 21; /* 21 times 8 bits = 168 */
+ memset(user.hours, 0xff, user.hours_len); /* available at all hours */
+ user.unknown_5 = 0x00020000; /* don't know */
+ user.unknown_5 = 0x000004ec; /* don't know */
+
+ return &user;
+}
+
+/*************************************************************************
+ Routine to return the next entry in the smbpasswd list.
do not call this function directly. use passdb.c instead.