* by ano: use more uniq name in the ldap module; the old one clashed in solaris.
[citadel.git] / citadel / ldap.c
index 7a93098e59695a9e4fa5b0ab4057c23609682b96..0a4cb2c44a49fee407c10fb2794882b3c48e1c86 100644 (file)
@@ -1,9 +1,15 @@
 /*
- * 
+ * $Id$
+ *
+ * These functions implement the portions of AUTHMODE_LDAP and AUTHMODE_LDAP_AD which
+ * actually speak to the LDAP server.
+ *
+ * Copyright (c) 2009 by Art Cancro and the citadel.org development team.
+ * This program is released under the terms of the GNU General Public License v3
  */
 
 
-int ldap_version = 3;
+int ctdl_require_ldap_version = 3;
 
 
 #include "sysdep.h"
@@ -83,7 +89,7 @@ int CtdlTryUserLDAP(char *username,
                return(errno);
        }
 
-       ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ldap_version);
+       ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ctdl_require_ldap_version);
 
        striplt(config.c_ldap_bind_dn);
        striplt(config.c_ldap_bind_pw);
@@ -211,7 +217,7 @@ int CtdlTryPasswordLDAP(char *user_dn, char *password)
 
        ldserver = ldap_init(config.c_ldap_host, config.c_ldap_port);
        if (ldserver) {
-               ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ldap_version);
+               ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ctdl_require_ldap_version);
                i = ldap_simple_bind_s(ldserver, user_dn, password);
                if (i == LDAP_SUCCESS) {
                        CtdlLogPrintf(CTDL_DEBUG, "LDAP: bind succeeded\n");
@@ -230,6 +236,27 @@ int CtdlTryPasswordLDAP(char *user_dn, char *password)
 }
 
 
+/*
+ * Learn LDAP attributes and stuff them into the vCard.
+ * Returns nonzero if we changed anything.
+ */
+int Ctdl_LDAP_to_vCard(char *ldap_dn, struct vCard *v)
+{
+       if (!ldap_dn) return(0);
+       if (!v) return(0);
+
+       /*
+        * FIXME LDAPSTUB this is a stub function
+        *
+        * ldap_dn will contain the DN of the user, and v will contain a pointer to
+        * the vCard that needs to be (re-)populated.  Put the requisite LDAP code here.
+        *
+       vcard_set_prop(v, "email;internet", xxx, 0);
+       return(1);      * return nonzero to tell the caller that we made changes that need to be saved *
+        *
+        */
 
+       return(0);      /* return zero to tell the caller that we didn't make any changes */
+}
 
 #endif /* HAVE_LDAP */