Regenerate
[samba.git] / docs / htmldocs / pdb-mysql.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >Passdb MySQL plugin</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.77+"><LINK
9 REL="HOME"
10 TITLE="SAMBA Project Documentation"
11 HREF="samba-howto-collection.html"><LINK
12 REL="UP"
13 TITLE="Optional configuration"
14 HREF="optional.html"><LINK
15 REL="PREVIOUS"
16 TITLE="Unified Logons between Windows NT and UNIX using Winbind"
17 HREF="winbind.html"><LINK
18 REL="NEXT"
19 TITLE="Passdb XML plugin"
20 HREF="pdb-xml.html"></HEAD
21 ><BODY
22 CLASS="CHAPTER"
23 BGCOLOR="#FFFFFF"
24 TEXT="#000000"
25 LINK="#0000FF"
26 VLINK="#840084"
27 ALINK="#0000FF"
28 ><DIV
29 CLASS="NAVHEADER"
30 ><TABLE
31 SUMMARY="Header navigation table"
32 WIDTH="100%"
33 BORDER="0"
34 CELLPADDING="0"
35 CELLSPACING="0"
36 ><TR
37 ><TH
38 COLSPAN="3"
39 ALIGN="center"
40 >SAMBA Project Documentation</TH
41 ></TR
42 ><TR
43 ><TD
44 WIDTH="10%"
45 ALIGN="left"
46 VALIGN="bottom"
47 ><A
48 HREF="winbind.html"
49 ACCESSKEY="P"
50 >Prev</A
51 ></TD
52 ><TD
53 WIDTH="80%"
54 ALIGN="center"
55 VALIGN="bottom"
56 ></TD
57 ><TD
58 WIDTH="10%"
59 ALIGN="right"
60 VALIGN="bottom"
61 ><A
62 HREF="pdb-xml.html"
63 ACCESSKEY="N"
64 >Next</A
65 ></TD
66 ></TR
67 ></TABLE
68 ><HR
69 ALIGN="LEFT"
70 WIDTH="100%"></DIV
71 ><DIV
72 CLASS="CHAPTER"
73 ><H1
74 ><A
75 NAME="PDB-MYSQL"
76 ></A
77 >Chapter 16. Passdb MySQL plugin</H1
78 ><DIV
79 CLASS="SECT1"
80 ><H1
81 CLASS="SECT1"
82 ><A
83 NAME="AEN2562"
84 ></A
85 >16.1. Building</H1
86 ><P
87 >To build the plugin, run <B
88 CLASS="COMMAND"
89 >make bin/pdb_mysql.so</B
90 >
91 in the <TT
92 CLASS="FILENAME"
93 >source/</TT
94 > directory of samba distribution. </P
95 ><P
96 >Next, copy pdb_mysql.so to any location you want. I 
97 strongly recommend installing it in $PREFIX/lib or /usr/lib/samba/</P
98 ></DIV
99 ><DIV
100 CLASS="SECT1"
101 ><H1
102 CLASS="SECT1"
103 ><A
104 NAME="AEN2568"
105 ></A
106 >16.2. Creating the database</H1
107 ><P
108 >You either can set up your own table and specify the field names to pdb_mysql (see below
109 for the column names) or use the default table. The file <TT
110 CLASS="FILENAME"
111 >examples/pdb/mysql/mysql.dump</TT
112
113 contains the correct queries to create the required tables. Use the command :
114
115 <B
116 CLASS="COMMAND"
117 >mysql -u<TT
118 CLASS="REPLACEABLE"
119 ><I
120 >username</I
121 ></TT
122 > -h<TT
123 CLASS="REPLACEABLE"
124 ><I
125 >hostname</I
126 ></TT
127 > -p<TT
128 CLASS="REPLACEABLE"
129 ><I
130 >password</I
131 ></TT
132 > <TT
133 CLASS="REPLACEABLE"
134 ><I
135 >databasename</I
136 ></TT
137 > &#60; <TT
138 CLASS="FILENAME"
139 >/path/to/samba/examples/pdb/mysql/mysql.dump</TT
140 ></B
141 >&#13;</P
142 ></DIV
143 ><DIV
144 CLASS="SECT1"
145 ><H1
146 CLASS="SECT1"
147 ><A
148 NAME="AEN2578"
149 ></A
150 >16.3. Configuring</H1
151 ><P
152 >This plugin lacks some good documentation, but here is some short info:</P
153 ><P
154 >Add a the following to the <B
155 CLASS="COMMAND"
156 >passdb backend</B
157 > variable in your <TT
158 CLASS="FILENAME"
159 >smb.conf</TT
160 >:
161 <PRE
162 CLASS="PROGRAMLISTING"
163 >passdb backend = [other-plugins] plugin:/location/to/pdb_mysql.so:identifier [other-plugins]</PRE
164 ></P
165 ><P
166 >The identifier can be any string you like, as long as it doesn't collide with 
167 the identifiers of other plugins or other instances of pdb_mysql. If you 
168 specify multiple pdb_mysql.so entries in 'passdb backend', you also need to 
169 use different identifiers!</P
170 ><P
171 >Additional options can be given thru the smb.conf file in the [global] section.</P
172 ><P
173 ><PRE
174 CLASS="PROGRAMLISTING"
175 >identifier:mysql host                     - host name, defaults to 'localhost'
176 identifier:mysql password
177 identifier:mysql user                     - defaults to 'samba'
178 identifier:mysql database                 - defaults to 'samba'
179 identifier:mysql port                     - defaults to 3306
180 identifier:table                          - Name of the table containing users</PRE
181 ></P
182 ><P
183 ><SPAN
184 CLASS="emphasis"
185 ><I
186 CLASS="EMPHASIS"
187 >WARNING: since the password for the mysql user is stored in the 
188 smb.conf file, you should make the the smb.conf file 
189 readable only to the user that runs samba. This is considered a security 
190 bug and will be fixed soon.</I
191 ></SPAN
192 ></P
193 ><P
194 >Names of the columns in this table(I've added column types those columns should have first):</P
195 ><P
196 ><PRE
197 CLASS="PROGRAMLISTING"
198 >identifier:logon time column             - int(9)
199 identifier:logoff time column            - int(9)
200 identifier:kickoff time column           - int(9)
201 identifier:pass last set time column     - int(9)
202 identifier:pass can change time column   - int(9)
203 identifier:pass must change time column  - int(9)
204 identifier:username column               - varchar(255) - unix username
205 identifier:domain column                 - varchar(255) - NT domain user is part of
206 identifier:nt username column            - varchar(255) - NT username
207 identifier:fullname column            - varchar(255) - Full name of user
208 identifier:home dir column               - varchar(255) - Unix homedir path
209 identifier:dir drive column              - varchar(2) - Directory drive path (eg: 'H:')
210 identifier:logon script column           - varchar(255) - Batch file to run on client side when logging on
211 identifier:profile path column           - varchar(255) - Path of profile
212 identifier:acct desc column              - varchar(255) - Some ASCII NT user data
213 identifier:workstations column           - varchar(255) - Workstations user can logon to (or NULL for all)
214 identifier:unknown string column         - varchar(255) - unknown string
215 identifier:munged dial column            - varchar(255) - ?
216 identifier:uid column                    - int(9) - Unix user ID (uid)
217 identifier:gid column                    - int(9) - Unix user group (gid)
218 identifier:user sid column               - varchar(255) - NT user SID
219 identifier:group sid column              - varchar(255) - NT group ID
220 identifier:lanman pass column            - varchar(255) - encrypted lanman password
221 identifier:nt pass column                - varchar(255) - encrypted nt passwd
222 identifier:plain pass column             - varchar(255) - plaintext password
223 identifier:acct control column           - int(9) - nt user data
224 identifier:unknown 3 column              - int(9) - unknown
225 identifier:logon divs column             - int(9) - ?
226 identifier:hours len column              - int(9) - ?
227 identifier:unknown 5 column              - int(9) - unknown
228 identifier:unknown 6 column              - int(9) - unknown</PRE
229 ></P
230 ><P
231 >Eventually, you can put a colon (:) after the name of each column, which 
232 should specify the column to update when updating the table. You can also
233 specify nothing behind the colon - then the data from the field will not be 
234 updated. </P
235 ></DIV
236 ><DIV
237 CLASS="SECT1"
238 ><H1
239 CLASS="SECT1"
240 ><A
241 NAME="AEN2595"
242 ></A
243 >16.4. Using plaintext passwords or encrypted password</H1
244 ><P
245 >I strongly discourage the use of plaintext passwords, however, you can use them:</P
246 ><P
247 >If you would like to use plaintext passwords, set 'identifier:lanman pass column' and 'identifier:nt pass column' to 'NULL' (without the quotes) and 'identifier:plain pass column' to the name of the column containing the plaintext passwords. </P
248 ><P
249 >If you use encrypted passwords, set the 'identifier:plain pass column' to 'NULL' (without the quotes). This is the default.</P
250 ></DIV
251 ><DIV
252 CLASS="SECT1"
253 ><H1
254 CLASS="SECT1"
255 ><A
256 NAME="AEN2600"
257 ></A
258 >16.5. Getting non-column data from the table</H1
259 ><P
260 >It is possible to have not all data in the database and making some 'constant'.</P
261 ><P
262 >For example, you can set 'identifier:fullname column' to : 
263 <B
264 CLASS="COMMAND"
265 >CONCAT(First_name,' ',Sur_name)</B
266 ></P
267 ><P
268 >Or, set 'identifier:workstations column' to :
269 <B
270 CLASS="COMMAND"
271 >NULL</B
272 ></P
273 ><P
274 >See the MySQL documentation for more language constructs.</P
275 ></DIV
276 ></DIV
277 ><DIV
278 CLASS="NAVFOOTER"
279 ><HR
280 ALIGN="LEFT"
281 WIDTH="100%"><TABLE
282 SUMMARY="Footer navigation table"
283 WIDTH="100%"
284 BORDER="0"
285 CELLPADDING="0"
286 CELLSPACING="0"
287 ><TR
288 ><TD
289 WIDTH="33%"
290 ALIGN="left"
291 VALIGN="top"
292 ><A
293 HREF="winbind.html"
294 ACCESSKEY="P"
295 >Prev</A
296 ></TD
297 ><TD
298 WIDTH="34%"
299 ALIGN="center"
300 VALIGN="top"
301 ><A
302 HREF="samba-howto-collection.html"
303 ACCESSKEY="H"
304 >Home</A
305 ></TD
306 ><TD
307 WIDTH="33%"
308 ALIGN="right"
309 VALIGN="top"
310 ><A
311 HREF="pdb-xml.html"
312 ACCESSKEY="N"
313 >Next</A
314 ></TD
315 ></TR
316 ><TR
317 ><TD
318 WIDTH="33%"
319 ALIGN="left"
320 VALIGN="top"
321 >Unified Logons between Windows NT and UNIX using Winbind</TD
322 ><TD
323 WIDTH="34%"
324 ALIGN="center"
325 VALIGN="top"
326 ><A
327 HREF="optional.html"
328 ACCESSKEY="U"
329 >Up</A
330 ></TD
331 ><TD
332 WIDTH="33%"
333 ALIGN="right"
334 VALIGN="top"
335 >Passdb XML plugin</TD
336 ></TR
337 ></TABLE
338 ></DIV
339 ></BODY
340 ></HTML
341 >