OpenVAS Libraries  4.0+rc3.SVN
ldap_auth.h
1 /* OpenVAS Libraries
2  * $Id$
3  * Description: Header for LDAP Authentication module.
4  *
5  * Authors:
6  * Felix Wolfsteller <felix.wolfsteller@intevation.de>
7  *
8  * Copyright:
9  * Copyright (C) 2010 Greenbone Networks GmbH
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2,
13  * or, at your option, any later version as published by the Free
14  * Software Foundation
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
26 #ifndef ENABLE_LDAP_AUTH
27 // Handle cases where openldap is not available.
28 #else
29 
30 #ifndef LDAP_AUTH_H
31 #define LDAP_AUTH_H
32 
33 #include <glib.h>
34 #include <ldap.h>
35 
42 struct ldap_auth_info
43 {
44  gchar *ldap_host;
45  gchar *auth_dn;
46 
48  gchar *role_attribute;
49  gchar **role_admin_values;
50  gchar **role_user_values;
51  gchar *ruletype_attribute;
52  gchar *rule_attribute;
53  gboolean allow_plaintext;
54 };
55 
57 typedef struct ldap_auth_info *ldap_auth_info_t;
58 
59 
60 ldap_auth_info_t ldap_auth_info_new (const gchar * ldap_host,
61  const gchar * auth_dn,
62  const gchar * role_attribute,
63  gchar ** role_user_values,
64  gchar ** role_admin_values,
65  const gchar * ruletype_attribute,
66  const gchar * rule_attribute,
67  gboolean allow_plaintext);
68 
69 void ldap_auth_info_free (ldap_auth_info_t info);
70 
71 int ldap_authenticate (const gchar * username, const gchar * password,
72  /*ldap_auth_info_t */ void *info);
73 
74 int
75 ldap_auth_query_role (LDAP * ldap, ldap_auth_info_t auth_info, const gchar * dn);
76 
77 int
78 ldap_auth_query_rules (LDAP * ldap, ldap_auth_info_t auth_info,
79  const gchar * dn, const gchar * username);
80 
81 ldap_auth_info_t ldap_auth_info_from_key_file (GKeyFile * keyfile,
82  const gchar * group);
83 
84 GSList*
85 ldap_auth_query (LDAP* ldap, const gchar* dn, const gchar* filter,
86  const gchar* attribute);
87 
88 LDAP *
89 ldap_auth_bind (const gchar * host, const gchar * userdn,
90  const gchar * password, gboolean force_starttls);
91 
92 GSList*
93 ldap_auth_bind_query (const gchar* host,
94  const gchar* userdn,
95  const gchar* username,
96  const gchar* password,
97  const gchar* dn,
98  const gchar* filter,
99  const gchar* attribute);
100 
101 #endif /* not LDAP_AUTH_H */
102 
103 #endif /* ENABLE_LDAP_AUTH */