r23779: Change from v2 or later to v3 or later.
[ira/wip.git] / source3 / include / nss_info.h
1 /* 
2    Unix SMB/CIFS implementation.
3    Idmap NSS headers
4
5    Copyright (C) Gerald Carter             2006
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Library General Public
9    License as published by the Free Software Foundation; either
10    version 2 of the License, or (at your option) any later version.
11    
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Library General Public License for more details.
16    
17    You should have received a copy of the GNU Library General Public
18    License along with this library; if not, write to the
19    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20    Boston, MA  02111-1307, USA.   
21 */
22
23 #ifndef _IDMAP_NSS_H
24 #define _IDMAP_NSS_H
25
26 #ifndef HAVE_LDAP
27 #  ifndef LDAPMessage
28 #    define LDAPMessage void
29 #  endif
30 #endif
31
32 /* The interface version specifier */
33
34 #define SMB_NSS_INFO_INTERFACE_VERSION    1
35
36 /* List of available backends.  All backends must 
37    register themselves */
38
39 struct nss_function_entry {
40         struct nss_function_entry *prev, *next;
41         
42         const char *name;
43         struct nss_info_methods *methods;
44 };
45
46 /* List of configured domains.  Each domain points 
47    back to its configured backend. */
48
49 struct nss_domain_entry {
50         struct nss_domain_entry *prev, *next;
51
52         const char *domain;
53
54         NTSTATUS init_status;   
55         struct nss_function_entry *backend;
56
57         /* hold state on a per domain basis */
58
59         void *state;
60 };
61
62 /* API */
63
64 struct nss_info_methods {
65         NTSTATUS (*init)( struct nss_domain_entry *e );
66         NTSTATUS (*get_nss_info)( struct nss_domain_entry *e, 
67                                   const DOM_SID *sid, 
68                                   TALLOC_CTX *ctx, 
69                                   ADS_STRUCT *ads, LDAPMessage *msg,
70                                   char **homedir, char **shell, char **gecos, gid_t *p_gid);
71         NTSTATUS (*close_fn)( void );
72 };
73
74
75 /* The following definitions come from nsswitch/nss_info.c  */
76
77 NTSTATUS smb_register_idmap_nss(int version, 
78                                 const char *name, 
79                                 struct nss_info_methods *methods);
80
81 NTSTATUS nss_init( const char **nss_list );
82
83 NTSTATUS nss_get_info( const char *domain, const DOM_SID *user_sid,
84                        TALLOC_CTX *ctx,
85                        ADS_STRUCT *ads, LDAPMessage *msg,
86                        char **homedir, char **shell, char **gecos,
87                        gid_t *p_gid);
88
89 NTSTATUS nss_close( const char *parameters );
90
91 #endif /* _IDMAP_NSS_H_ */
92