summaryrefslogtreecommitdiff
path: root/source3/passdb/passdb.c
blob: 9e5b3ef1454e8b376409a33a20c6c77f23d2af1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* 
   Unix SMB/Netbios implementation.
   Version 1.9.
   Password and authentication handling
   Copyright (C) Andrew Tridgell 1992-1998
   Copyright (C) Luke Kenneth Casson Leighton 1996-1998
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "includes.h"

extern int DEBUGLEVEL;

/************************************************************************
 Routine to search sam passwd by name.
*************************************************************************/

struct smb_passwd *getsampwnam(char *name)
{
#ifdef USE_LDAP
  return getldappwnam(name);
#else
  return getsmbpwnam(name);
#endif /* USE_LDAP */
}

/************************************************************************
 Routine to search sam passwd by uid.
*************************************************************************/

struct smb_passwd *getsampwuid(unsigned int uid)
{
#ifdef USE_LDAP
  return getldappwuid(uid);
#else
  return getsmbpwuid(uid);
#endif /* USE_LDAP */
}

/***************************************************************
 Start to enumerate the sam passwd list. Returns a void pointer
 to ensure no modification outside this module.
****************************************************************/

void *startsampwent(BOOL update)
{
#ifdef USE_LDAP
  return startldappwent(update);
#else
  return startsmbpwent(update);
#endif /* USE_LDAP */
}

/***************************************************************
 End enumeration of the sam passwd list.
****************************************************************/

void endsampwent(void *vp)
{
#ifdef USE_LDAP
  endldappwent(vp);
#else
  endsmbpwent(vp);
#endif /* USE_LDAP */
}

/*************************************************************************
 Routine to return the next entry in the sam passwd list.
 *************************************************************************/

struct smb_passwd *getsampwent(void *vp)
{
#ifdef USE_LDAP
  return getldappwent(vp);
#else
  return getsmbpwent(vp);
#endif /* USE_LDAP */
}

/*************************************************************************
 Return the current position in the sam passwd list as an unsigned long.
 This must be treated as an opaque token.
 *************************************************************************/
unsigned long getsampwpos(void *vp)
{
#ifdef USE_LDAP
  return getldappwpos(vp);
#else
  return getsmbpwpos(vp);
#endif /* USE_LDAP */
}

/*************************************************************************
 Set the current position in the sam passwd list from unsigned long.
 This must be treated as an opaque token.
 *************************************************************************/
BOOL setsampwpos(void *vp, unsigned long tok)
{
#ifdef USE_LDAP
  return setldappwpos(vp, tok);
#else
  return setsmbpwpos(vp, tok);
#endif /* USE_LDAP */
}

/************************************************************************
 Routine to add an entry to the sam passwd file.
*************************************************************************/

BOOL add_sampwd_entry(struct smb_passwd *newpwd)
{
#ifdef USE_LDAP
  return add_ldappwd_entry(newpwd);
#else
  return add_smbpwd_entry(newpwd);
#endif /* USE_LDAP */
}

/************************************************************************
 Routine to search the sam passwd file for an entry matching the username.
 and then modify its password entry. We can't use the startsampwent()/
 getsampwent()/endsampwent() interfaces here as we depend on looking
 in the actual file to decide how much room we have to write data.
 override = False, normal
 override = True, override XXXXXXXX'd out password or NO PASS
************************************************************************/

BOOL mod_sampwd_entry(struct smb_passwd* pwd, BOOL override)
{
#ifdef USE_LDAP
  return mod_ldappwd_entry(pwd, override);
#else
  return mod_smbpwd_entry(pwd, override);
#endif /* USE_LDAP */
}