Now editing a Vcard in the GAB room updates the ldap entry but only
if it is the users own ldap entry.
{
if (!dirserver) return;
{
if (!dirserver) return;
- lprintf(CTDL_INFO, "Unbinding from directory server\n");
+ lprintf(CTDL_INFO, "LDAP: Unbinding from directory server\n");
ldap_unbind(dirserver);
dirserver = NULL;
}
ldap_unbind(dirserver);
dirserver = NULL;
}
mods[2] = NULL;
/* Perform the transaction */
mods[2] = NULL;
/* Perform the transaction */
- lprintf(CTDL_DEBUG, "Setting up Base DN node...\n");
+ lprintf(CTDL_DEBUG, "LDAP: Setting up Base DN node...\n");
begin_critical_section(S_LDAP);
i = ldap_add_s(dirserver, config.c_ldap_base_dn, mods);
end_critical_section(S_LDAP);
if (i == LDAP_ALREADY_EXISTS) {
begin_critical_section(S_LDAP);
i = ldap_add_s(dirserver, config.c_ldap_base_dn, mods);
end_critical_section(S_LDAP);
if (i == LDAP_ALREADY_EXISTS) {
- lprintf(CTDL_INFO, "Base DN is already present in the directory; no need to add it again.\n");
+ lprintf(CTDL_INFO, "LDAP: Base DN is already present in the directory; no need to add it again.\n");
}
else if (i != LDAP_SUCCESS) {
}
else if (i != LDAP_SUCCESS) {
- lprintf(CTDL_CRIT, "ldap_add_s() failed: %s (%d)\n",
+ lprintf(CTDL_CRIT, "LDAP: ldap_add_s() failed: %s (%d)\n",
ldap_err2string(i), i);
}
}
ldap_err2string(i), i);
}
}
mods[2] = NULL;
/* Perform the transaction */
mods[2] = NULL;
/* Perform the transaction */
- lprintf(CTDL_DEBUG, "Setting up Host OU node...\n");
+ lprintf(CTDL_DEBUG, "LDAP: Setting up Host OU node...\n");
begin_critical_section(S_LDAP);
i = ldap_add_s(dirserver, dn, mods);
end_critical_section(S_LDAP);
if (i == LDAP_ALREADY_EXISTS) {
begin_critical_section(S_LDAP);
i = ldap_add_s(dirserver, dn, mods);
end_critical_section(S_LDAP);
if (i == LDAP_ALREADY_EXISTS) {
- lprintf(CTDL_INFO, "Host OU is already present in the directory; no need to add it again.\n");
+ lprintf(CTDL_INFO, "LDAP: Host OU is already present in the directory; no need to add it again.\n");
}
else if (i != LDAP_SUCCESS) {
}
else if (i != LDAP_SUCCESS) {
- lprintf(CTDL_CRIT, "ldap_add_s() failed: %s (%d)\n",
+ lprintf(CTDL_CRIT, "LDAP: ldap_add_s() failed: %s (%d)\n",
ldap_err2string(i), i);
return -1;
}
ldap_err2string(i), i);
return -1;
}
int i;
int ldap_version = 3;
int i;
int ldap_version = 3;
- lprintf(CTDL_INFO, "Connecting to LDAP server %s:%d...\n",
+ lprintf(CTDL_INFO, "LDAP: Connecting to LDAP server %s:%d...\n",
config.c_ldap_host, config.c_ldap_port);
dirserver = ldap_init(config.c_ldap_host, config.c_ldap_port);
if (dirserver == NULL) {
config.c_ldap_host, config.c_ldap_port);
dirserver = ldap_init(config.c_ldap_host, config.c_ldap_port);
if (dirserver == NULL) {
- lprintf(CTDL_CRIT, "Could not connect to %s:%d : %s\n",
+ lprintf(CTDL_CRIT, "LDAP: Could not connect to %s:%d : %s\n",
config.c_ldap_host,
config.c_ldap_port,
strerror(errno));
config.c_ldap_host,
config.c_ldap_port,
strerror(errno));
ldap_set_option(dirserver, LDAP_OPT_PROTOCOL_VERSION, &ldap_version);
ldap_set_option(dirserver, LDAP_OPT_PROTOCOL_VERSION, &ldap_version);
- lprintf(CTDL_INFO, "Binding to %s\n", config.c_ldap_bind_dn);
+ lprintf(CTDL_INFO, "LDAP: Binding to %s\n", config.c_ldap_bind_dn);
i = ldap_simple_bind_s(dirserver,
config.c_ldap_bind_dn,
config.c_ldap_bind_pw
);
if (i != LDAP_SUCCESS) {
i = ldap_simple_bind_s(dirserver,
config.c_ldap_bind_dn,
config.c_ldap_bind_pw
);
if (i != LDAP_SUCCESS) {
- lprintf(CTDL_CRIT, "Cannot bind: %s (%d)\n", ldap_err2string(i), i);
+ lprintf(CTDL_CRIT, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i);
dirserver = NULL; /* FIXME disconnect from ldap */
return;
}
dirserver = NULL; /* FIXME disconnect from ldap */
return;
}
int CtdlCreateLdapObject(char *cn, char *ou, void **object)
{
// We do nothing here, this just gets the base structure created by the interface.
int CtdlCreateLdapObject(char *cn, char *ou, void **object)
{
// We do nothing here, this just gets the base structure created by the interface.
- lprintf (CTDL_DEBUG, "Created ldap object\n");
+ lprintf (CTDL_DEBUG, "LDAP: Created ldap object\n");
- lprintf (CTDL_DEBUG, "Adding ldap attribute\n");
+ lprintf (CTDL_DEBUG, "LDAP: Adding ldap attribute name:\"%s\" vlaue:\"%s\"\n", cn, ou);
attrs = *object;
if (attrs)
attrs = *object;
if (attrs)
- lprintf(CTDL_DEBUG, "Calling ldap_add_s() for '%s'\n", this_dn);
+ lprintf(CTDL_DEBUG, "LDAP: Calling ldap_add_s() for '%s'\n", this_dn);
begin_critical_section(S_LDAP);
i = ldap_add_s(dirserver, this_dn, attrs);
begin_critical_section(S_LDAP);
i = ldap_add_s(dirserver, this_dn, attrs);
for (j=0; j<(num_attrs); ++j) {
attrs[j]->mod_op = LDAP_MOD_REPLACE;
}
for (j=0; j<(num_attrs); ++j) {
attrs[j]->mod_op = LDAP_MOD_REPLACE;
}
- lprintf(CTDL_DEBUG, "Calling ldap_modify_s() for '%s'\n", this_dn);
+ lprintf(CTDL_DEBUG, "LDAP: Calling ldap_modify_s() for '%s'\n", this_dn);
begin_critical_section(S_LDAP);
i = ldap_modify_s(dirserver, this_dn, attrs);
end_critical_section(S_LDAP);
}
if (i != LDAP_SUCCESS) {
begin_critical_section(S_LDAP);
i = ldap_modify_s(dirserver, this_dn, attrs);
end_critical_section(S_LDAP);
}
if (i != LDAP_SUCCESS) {
- lprintf(CTDL_ERR, "ldap_add_s() failed: %s (%d)\n",
+ lprintf(CTDL_ERR, "LDAP: ldap_add_s() failed: %s (%d)\n",
ldap_err2string(i), i);
return -1;
}
ldap_err2string(i), i);
return -1;
}
- lprintf(CTDL_DEBUG, "Freeing attributes\n");
+ lprintf(CTDL_DEBUG, "LDAP: Freeing attributes\n");
/* Free the attributes */
for (i=0; i<num_attrs; ++i) {
if (attrs[i] != NULL) {
/* Free the attributes */
for (i=0; i<num_attrs; ++i) {
if (attrs[i] != NULL) {
sprintf(this_dn, "cn=%s,ou=%s,%s", cn, ou, config.c_ldap_base_dn);
sprintf(this_dn, "cn=%s,ou=%s,%s", cn, ou, config.c_ldap_base_dn);
- lprintf(CTDL_DEBUG, "Calling ldap_delete_s()\n");
+ lprintf(CTDL_DEBUG, "LDAP: Calling ldap_delete_s()\n");
begin_critical_section(S_LDAP);
i = ldap_delete_s(dirserver, this_dn);
end_critical_section(S_LDAP);
if (i != LDAP_SUCCESS) {
begin_critical_section(S_LDAP);
i = ldap_delete_s(dirserver, this_dn);
end_critical_section(S_LDAP);
if (i != LDAP_SUCCESS) {
- lprintf(CTDL_ERR, "ldap_delete_s() failed: %s (%d)\n",
+ lprintf(CTDL_ERR, "LDAP: ldap_delete_s() failed: %s (%d)\n",
ldap_err2string(i), i);
return -1;
}
ldap_err2string(i), i);
return -1;
}
--- /dev/null
+/*
+ * $Id$
+ *
+ */
+
+#ifdef HAVE_LDAP
+
+void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op);
+
+#endif /* HAVE_LDAP */
int linelen;
long I;
struct vCard *v;
int linelen;
long I;
struct vCard *v;
+ int is_UserConf=0;
+ int is_GAB=0;
if (!CC->logged_in) return(0); /* Only do this if logged in. */
if (!CC->logged_in) return(0); /* Only do this if logged in. */
* message, don't bother.
*/
if (msg->cm_fields['O'] == NULL) return(0);
* message, don't bother.
*/
if (msg->cm_fields['O'] == NULL) return(0);
- if (strcasecmp(msg->cm_fields['O'], USERCONFIGROOM)) return(0);
+ if (!strcasecmp(msg->cm_fields['O'], USERCONFIGROOM)) is_UserConf = 1;
+ if (!strcasecmp(msg->cm_fields['O'], ADDRESS_BOOK_ROOM)) is_GAB = 1;
+ if (!is_UserConf && !is_GAB) return(0);
if (msg->cm_format_type != 4) return(0);
ptr = msg->cm_fields['M'];
if (msg->cm_format_type != 4) return(0);
ptr = msg->cm_fields['M'];
extract_friendly_name(CC->cs_inet_fn, sizeof CC->cs_inet_fn, v);
vcard_free(v);
extract_friendly_name(CC->cs_inet_fn, sizeof CC->cs_inet_fn, v);
vcard_free(v);
- /* Put it in the Global Address Book room... */
- CtdlSaveMsgPointerInRoom(ADDRESS_BOOK_ROOM, I, 1, msg);
+ if (!is_GAB)
+ { // This is not the GAB
+ /* Put it in the Global Address Book room... */
+ CtdlSaveMsgPointerInRoom(ADDRESS_BOOK_ROOM, I, 1, msg);
+ }
/* ...and also in the directory database. */
vcard_add_to_directory(I, NULL);
/* ...and also in the directory database. */
vcard_add_to_directory(I, NULL);
+++ /dev/null
-/*
- * $Id$
- *
- */
-
-#ifdef HAVE_LDAP
-
-void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op);
-
-#endif /* HAVE_LDAP */