summaryrefslogtreecommitdiff
path: root/source3/include/nss_info.h
blob: 9b910ca256728d09799b6b5c928a46069886ffd7 (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
/* 
   Unix SMB/CIFS implementation.
   Idmap NSS headers

   Copyright (C) Gerald Carter             2006

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _IDMAP_NSS_H
#define _IDMAP_NSS_H

#ifndef HAVE_LDAP
#  ifndef LDAPMessage
#    define LDAPMessage void
#  endif
#endif

/* The interface version specifier */

#define SMB_NSS_INFO_INTERFACE_VERSION	  1

/* List of available backends.  All backends must 
   register themselves */

struct nss_function_entry {
	struct nss_function_entry *prev, *next;

	const char *name;
	struct nss_info_methods *methods;
};

/* List of configured domains.  Each domain points 
   back to its configured backend. */

struct nss_domain_entry {
	struct nss_domain_entry *prev, *next;

	const char *domain;

	NTSTATUS init_status;	
	struct nss_function_entry *backend;

	/* hold state on a per domain basis */

	void *state;
};

/* API */

struct nss_info_methods {
	NTSTATUS (*init)( struct nss_domain_entry *e );
	NTSTATUS (*get_nss_info)( struct nss_domain_entry *e, 
				  const struct dom_sid *sid,
				  TALLOC_CTX *ctx, 
				  ADS_STRUCT *ads, LDAPMessage *msg,
				  const char **homedir, const char **shell,
				  const char **gecos, gid_t *p_gid);
	NTSTATUS (*map_to_alias)(TALLOC_CTX *mem_ctx,
				 struct nss_domain_entry *e,
				 const char *name, char **alias);
	NTSTATUS (*map_from_alias)(TALLOC_CTX *mem_ctx,
				   struct nss_domain_entry *e,
				   const char *alias, char **name);
	NTSTATUS (*close_fn)( void );
};


/* The following definitions come from nsswitch/nss_info.c  */

NTSTATUS smb_register_idmap_nss(int version, 
				const char *name, 
				struct nss_info_methods *methods);

NTSTATUS nss_get_info( const char *domain, const struct dom_sid *user_sid,
		       TALLOC_CTX *ctx,
		       ADS_STRUCT *ads, LDAPMessage *msg,
		       const char **homedir, const char **shell,
		       const char **gecos, gid_t *p_gid);

NTSTATUS nss_map_to_alias( TALLOC_CTX *mem_ctx, const char *domain,
			   const char *name, char **alias );

NTSTATUS nss_map_from_alias( TALLOC_CTX *mem_ctx, const char *domain,
			     const char *alias, char **name );

NTSTATUS nss_close( const char *parameters );

#endif /* _IDMAP_NSS_H_ */