OpenVAS Libraries  4.0+rc3.SVN
misc/ldap_auth.h
00001 /* OpenVAS Libraries
00002  * $Id$
00003  * Description: Header for LDAP Authentication module.
00004  *
00005  * Authors:
00006  * Felix Wolfsteller <felix.wolfsteller@intevation.de>
00007  *
00008  * Copyright:
00009  * Copyright (C) 2010 Greenbone Networks GmbH
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License version 2,
00013  * or, at your option, any later version as published by the Free
00014  * Software Foundation
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
00024  */
00025 
00026 #ifndef ENABLE_LDAP_AUTH
00027 // Handle cases where openldap is not available.
00028 #else
00029 
00030 #ifndef LDAP_AUTH_H
00031 #define LDAP_AUTH_H
00032 
00033 #include <glib.h>
00034 #include <ldap.h>
00035 
00042 struct ldap_auth_info
00043 {
00044   gchar *ldap_host;             
00045   gchar *auth_dn;               
00046 
00048   gchar *role_attribute;
00049   gchar **role_admin_values;    
00050   gchar **role_user_values;     
00051   gchar *ruletype_attribute;    
00052   gchar *rule_attribute;        
00053   gboolean allow_plaintext;     
00054 };
00055 
00057 typedef struct ldap_auth_info *ldap_auth_info_t;
00058 
00059 
00060 ldap_auth_info_t ldap_auth_info_new (const gchar * ldap_host,
00061                                      const gchar * auth_dn,
00062                                      const gchar * role_attribute,
00063                                      gchar ** role_user_values,
00064                                      gchar ** role_admin_values,
00065                                      const gchar * ruletype_attribute,
00066                                      const gchar * rule_attribute,
00067                                      gboolean allow_plaintext);
00068 
00069 void ldap_auth_info_free (ldap_auth_info_t info);
00070 
00071 int ldap_authenticate (const gchar * username, const gchar * password,
00072                        /*ldap_auth_info_t */ void *info);
00073 
00074 int
00075 ldap_auth_query_role (LDAP * ldap, ldap_auth_info_t auth_info, const gchar * dn);
00076 
00077 int
00078 ldap_auth_query_rules (LDAP * ldap, ldap_auth_info_t auth_info,
00079                        const gchar * dn, const gchar * username);
00080 
00081 ldap_auth_info_t ldap_auth_info_from_key_file (GKeyFile * keyfile,
00082                                                const gchar * group);
00083 
00084 GSList*
00085 ldap_auth_query (LDAP* ldap, const gchar* dn, const gchar* filter,
00086                  const gchar* attribute);
00087 
00088 LDAP *
00089 ldap_auth_bind (const gchar * host, const gchar * userdn,
00090                 const gchar * password, gboolean force_starttls);
00091 
00092 GSList*
00093 ldap_auth_bind_query (const gchar* host,
00094                       const gchar* userdn,
00095                       const gchar* username,
00096                       const gchar* password,
00097                       const gchar* dn,
00098                       const gchar* filter,
00099                       const gchar* attribute);
00100 
00101 #endif /* not LDAP_AUTH_H */
00102 
00103 #endif /* ENABLE_LDAP_AUTH */