X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fmodules%2Fvcard%2Fserv_vcard.c;fp=citadel%2Fmodules%2Fvcard%2Fserv_vcard.c;h=39820f7762dc7a821609c060995ec6ecb99c77c0;hp=dad28b8dd508f1d2ec7b8832e81eddb6f2b7c367;hb=7ae9feb654f41173f99e96ba617d018e990da80c;hpb=3c56420d6f7066dd0d09cd404617dee3c429ab18 diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index dad28b8dd..39820f776 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -441,18 +441,19 @@ int vcard_upload_beforesave(struct CtdlMessage *msg, recptypes *recp) { vcard_set_prop(v, "FBURL;PREF", buf, 0); } - /* If the vCard has no UID, then give it one. */ + s = vcard_get_prop(v, "UID", 1, 0, 0); - if (s == NULL) { + if (s == NULL) { /* Note LDAP auth sets UID from the LDAP UUID, use that if it exists. */ + /* Enforce local UID policy if applicable */ + if (yes_my_citadel_config) { + snprintf(buf, sizeof buf, VCARD_EXT_FORMAT, msg->cm_fields[eAuthor], NODENAME); + } else { + /* If the vCard has no UID, then give it one. */ generate_uuid(buf); - vcard_set_prop(v, "UID", buf, 0); - } + } + vcard_set_prop(v, "UID", buf, 0); + } - /* Enforce local UID policy if applicable */ - if (yes_my_citadel_config) { - snprintf(buf, sizeof buf, VCARD_EXT_FORMAT, msg->cm_fields[eAuthor], NODENAME); - vcard_set_prop(v, "UID", buf, 0); - } /* * Set the EUID of the message to the UID of the vCard. @@ -849,7 +850,9 @@ void vcard_newuser(struct ctdluser *usbuf) { char buf[256]; int i; struct vCard *v; + int need_default_vcard; + need_default_vcard =1; vcard_fn_to_n(vname, usbuf->fullname, sizeof vname); syslog(LOG_DEBUG, "Converted <%s> to <%s>", usbuf->fullname, vname); @@ -875,16 +878,11 @@ void vcard_newuser(struct ctdluser *usbuf) { #endif // HAVE_GETPWUID_R snprintf(buf, sizeof buf, "%s@%s", pwd.pw_name, config.c_fqdn); vcard_add_prop(v, "email;internet", buf); + need_default_vcard=0; } } #endif - /* Everyone gets an email address based on their display name */ - snprintf(buf, sizeof buf, "%s@%s", usbuf->fullname, config.c_fqdn); - for (i=0; buf[i]; ++i) { - if (buf[i] == ' ') buf[i] = '_'; - } - vcard_add_prop(v, "email;internet", buf); #ifdef HAVE_LDAP /* @@ -892,20 +890,29 @@ void vcard_newuser(struct ctdluser *usbuf) { * into the user's vCard. */ if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) { - uid_t ldap_uid; + //uid_t ldap_uid; int found_user; char ldap_cn[512]; char ldap_dn[512]; - found_user = CtdlTryUserLDAP(usbuf->fullname, ldap_dn, sizeof ldap_dn, ldap_cn, sizeof ldap_cn, &ldap_uid); + found_user = CtdlTryUserLDAP(usbuf->fullname, ldap_dn, sizeof ldap_dn, ldap_cn, sizeof ldap_cn, &usbuf->uid,1); if (found_user == 0) { if (Ctdl_LDAP_to_vCard(ldap_dn, v)) { /* Allow global address book and internet directory update without login long enough to write this. */ CC->vcard_updated_by_ldap++; /* Otherwise we'll only update the user config. */ + need_default_vcard=0; syslog(LOG_DEBUG, "LDAP Created Initial Vcard for %s\n",usbuf->fullname); } } } #endif + if (need_default_vcard!=0) { + /* Everyone gets an email address based on their display name */ + snprintf(buf, sizeof buf, "%s@%s", usbuf->fullname, config.c_fqdn); + for (i=0; buf[i]; ++i) { + if (buf[i] == ' ') buf[i] = '_'; + } + vcard_add_prop(v, "email;internet", buf); + } vcard_write_user(usbuf, v); vcard_free(v);