Example #1
0
/* Checks if created attributes are used in the RDN.
 * Returns 1 if created attrs are in the RDN, and
 * 0 if created attrs are not in the RDN. Returns
 * -1 if an error occurs.
 */
static int check_rdn_for_created_attrs(const char *newrdn)
{
	int i, rc = 0;
	Slapi_RDN *rdn = NULL;
	char *value = NULL;
	char *type[] = {"modifytimestamp", "createtimestamp",
			"creatorsname", "modifiersname", 0};

	if (newrdn && *newrdn && (rdn = slapi_rdn_new())) {
		slapi_rdn_init_dn(rdn, newrdn);
		for (i = 0; type[i] != NULL; i++) {
			if (slapi_rdn_contains_attr(rdn, type[i], &value)) {
				LDAPDebug(LDAP_DEBUG_TRACE, "Invalid DN. RDN contains %s attribute\n", type[i], 0, 0);
				rc = 1;
				break;
			}
		}
		slapi_rdn_free(&rdn);
	} else {
		LDAPDebug(LDAP_DEBUG_TRACE, "check_rdn_for_created_attrs: Error allocating RDN\n", 0, 0, 0);
		rc = -1;
	}

	return rc;
}
Example #2
0
File: add.c Project: Firstyear/ds
/* Checks if created attributes are used in the RDN.
 * Returns 1 if created attrs are in the RDN, and
 * 0 if created attrs are not in the RDN. Returns
 * -1 if an error occurred.
 */
static int check_rdn_for_created_attrs(Slapi_Entry *e)
{
    int i, rc = 0;
    Slapi_RDN *rdn = NULL;
    char *value = NULL;
    char *type[] = {SLAPI_ATTR_UNIQUEID, "modifytimestamp", "modifiersname", "internalmodifytimestamp",
                    "internalmodifiersname", "createtimestamp", "creatorsname", 0};

    if ((rdn = slapi_rdn_new())) {
        slapi_rdn_init_dn(rdn, slapi_entry_get_dn_const(e));

        for (i = 0; type[i] != NULL; i++) {
            if (slapi_rdn_contains_attr(rdn, type[i], &value)) {
                slapi_log_err(SLAPI_LOG_TRACE, "check_rdn_for_created_attrs",
                	"Invalid DN. RDN contains %s attribute\n", type[i]);
                rc = 1;
                break;
            }
        }

        slapi_rdn_free(&rdn);
    } else {
        slapi_log_err(SLAPI_LOG_TRACE, "check_rdn_for_created_attrs", "Error allocating RDN\n");
        rc = -1;
    }

    return rc;
}
Example #3
0
Slapi_RDN *slapi_rdn_new_dn( const char *dn )
{
	Slapi_RDN *rdn;

	rdn = slapi_rdn_new();
	slapi_rdn_init_dn( rdn, dn );
	return rdn;
}