1*f95714a4Smartijn /* 2*f95714a4Smartijn * $OpenBSD: login_ldap.h,v 1.1 2020/09/12 15:06:12 martijn Exp $ 3*f95714a4Smartijn * Copyright (c) 2002 Institute for Open Systems Technology Australia (IFOST) 4*f95714a4Smartijn * Copyright (c) 2007 Michael Erdely <merdely@openbsd.org> 5*f95714a4Smartijn * Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org> 6*f95714a4Smartijn * 7*f95714a4Smartijn * All rights reserved. 8*f95714a4Smartijn * 9*f95714a4Smartijn * Redistribution and use in source and binary forms, with or without 10*f95714a4Smartijn * modification, are permitted provided that the following conditions 11*f95714a4Smartijn * are met: 12*f95714a4Smartijn * 1. Redistributions of source code must retain the above copyright 13*f95714a4Smartijn * notice, this list of conditions and the following disclaimer. 14*f95714a4Smartijn * 2. Redistributions in binary form must reproduce the above copyright 15*f95714a4Smartijn * notice, this list of conditions and the following disclaimer in the 16*f95714a4Smartijn * documentation and/or other materials provided with the distribution. 17*f95714a4Smartijn * 3. The name of the author may not be used to endorse or promote products 18*f95714a4Smartijn * derived from this software without specific prior written permission. 19*f95714a4Smartijn * 20*f95714a4Smartijn * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 21*f95714a4Smartijn * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 22*f95714a4Smartijn * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23*f95714a4Smartijn * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24*f95714a4Smartijn * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25*f95714a4Smartijn * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26*f95714a4Smartijn * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27*f95714a4Smartijn * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28*f95714a4Smartijn * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29*f95714a4Smartijn * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30*f95714a4Smartijn */ 31*f95714a4Smartijn #ifndef __login_ldap_h 32*f95714a4Smartijn #define __login_ldap_h 33*f95714a4Smartijn 34*f95714a4Smartijn #include <sys/queue.h> 35*f95714a4Smartijn 36*f95714a4Smartijn #define DEFTIMEOUT 60 /* number of seconds to wait before a timeout */ 37*f95714a4Smartijn 38*f95714a4Smartijn struct aldap_urlq { 39*f95714a4Smartijn struct aldap_url s; 40*f95714a4Smartijn TAILQ_ENTRY(aldap_urlq) entries; 41*f95714a4Smartijn }; 42*f95714a4Smartijn 43*f95714a4Smartijn struct auth_ctx { 44*f95714a4Smartijn char *user; /* the user to authenticate */ 45*f95714a4Smartijn struct aldap *ld; /* ldap server connection */ 46*f95714a4Smartijn TAILQ_HEAD(, aldap_urlq) s; /* info about the servers */ 47*f95714a4Smartijn char *basedn;/* base dn for search, may be null */ 48*f95714a4Smartijn char *binddn;/* bind dn for search, may be null */ 49*f95714a4Smartijn char *bindpw;/* bind password for search, may be null */ 50*f95714a4Smartijn char *cacert; /* path to CA ssl certificate */ 51*f95714a4Smartijn char *cacertdir; 52*f95714a4Smartijn char *userdn; /* dn as returned from search */ 53*f95714a4Smartijn char *filter; 54*f95714a4Smartijn int scope; 55*f95714a4Smartijn int timeout; 56*f95714a4Smartijn char *gbasedn; 57*f95714a4Smartijn char *gfilter; 58*f95714a4Smartijn int gscope; 59*f95714a4Smartijn }; 60*f95714a4Smartijn 61*f95714a4Smartijn /* util.c */ 62*f95714a4Smartijn extern int debug; 63*f95714a4Smartijn 64*f95714a4Smartijn void dlog(int, char *, ...); 65*f95714a4Smartijn int parse_conf(struct auth_ctx *, const char *); 66*f95714a4Smartijn int conn(struct auth_ctx *); 67*f95714a4Smartijn int do_conn(struct auth_ctx *, struct aldap_url *); 68*f95714a4Smartijn char * parse_filter(struct auth_ctx *, const char *); 69*f95714a4Smartijn const char *ldap_resultcode(enum result_code code); 70*f95714a4Smartijn 71*f95714a4Smartijn /* bind.c */ 72*f95714a4Smartijn int bind_password(struct auth_ctx *, char *, char *); 73*f95714a4Smartijn int unbind(struct auth_ctx *); 74*f95714a4Smartijn 75*f95714a4Smartijn /* search.c */ 76*f95714a4Smartijn char * search(struct auth_ctx *, char *, char *, enum scope); 77*f95714a4Smartijn #endif /* __login_ldap_h */ 78