X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=contrib%2Fslapi-plugins%2Faddrdnvalues%2Faddrdnvalues.c;h=c3e97f6ca38235c6ba8588a43cca58413b44bf04;hb=55060f6b1f23c6e4276d8e10ef73eaf1f2a3ab3a;hp=243c4c9a3f836955a14a09ad96be9b1d8bff7815;hpb=016f3326242f76bd32d13b366950f1b68385b804;p=openldap
diff --git a/contrib/slapi-plugins/addrdnvalues/addrdnvalues.c b/contrib/slapi-plugins/addrdnvalues/addrdnvalues.c
index 243c4c9a3f..c3e97f6ca3 100644
--- a/contrib/slapi-plugins/addrdnvalues/addrdnvalues.c
+++ b/contrib/slapi-plugins/addrdnvalues/addrdnvalues.c
@@ -1,4 +1,8 @@
-/*
+/* addrdnvalues.c */
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 2003-2012 The OpenLDAP Foundation.
* Copyright 2003-2004 PADL Software Pty Ltd.
* All rights reserved.
*
@@ -10,11 +14,9 @@
* top-level directory of the distribution or, alternatively, at
* .
*/
-/* (C) Copyright PADL Software Pty Ltd. 2003
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that this notice is preserved
- * and that due credit is given to PADL Software Pty Ltd. This software
- * is provided ``as is'' without express or implied warranty.
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by Luke Howard of PADL Software
+ * for inclusion in OpenLDAP Software.
*/
#include
@@ -38,9 +40,6 @@ static int addrdnvalues_preop_add(Slapi_PBlock *pb)
{
int rc;
Slapi_Entry *e;
- char *szDN;
- LDAPDN dn;
- int i;
if (slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &e) != 0) {
slapi_log_error(SLAPI_LOG_PLUGIN, "addrdnvalues_preop_add",
@@ -48,40 +47,16 @@ static int addrdnvalues_preop_add(Slapi_PBlock *pb)
return -1;
}
- szDN = slapi_entry_get_dn(e);
- rc = ldap_str2dn(szDN, &dn, LDAP_DN_FORMAT_LDAPV3);
+ rc = slapi_entry_add_rdn_values(e);
if (rc != LDAP_SUCCESS) {
- slapi_send_ldap_result(pb, rc, NULL, NULL, 0, NULL);
- slapi_log_error(SLAPI_LOG_PLUGIN, "addrdnvalues_preop_add", "%s\n", ldap_err2string(rc));
+ slapi_send_ldap_result(pb, LDAP_OTHER, NULL,
+ "Failed to parse distinguished name", 0, NULL);
+ slapi_log_error(SLAPI_LOG_PLUGIN, "addrdnvalues_preop_add",
+ "Failed to parse distinguished name: %s\n",
+ ldap_err2string(rc));
return -1;
}
- if (dn[0] != NULL) {
- LDAPRDN rdn = dn[0];
-
- for (i = 0; rdn[i] != NULL; i++) {
- LDAPAVA *ava = &rdn[0][i];
- struct berval *vals[2];
- Slapi_Attr *a = NULL;
-
- /* 0 means attr exists */
- if (slapi_entry_attr_find(e, ava->la_attr.bv_val, &a) == 0 &&
- a != NULL &&
- slapi_attr_value_find(a, &ava->la_value) == 0)
- {
- /* RDN in entry */
- continue;
- } /* else RDN not in entry */
-
- vals[0] = &ava->la_value;
- vals[1] = NULL;
-
- slapi_entry_attr_merge(e, ava->la_attr.bv_val, vals);
- }
- }
-
- ldap_dnfree(dn);
-
return 0;
}