From: Luke Howard Date: Sun, 23 May 2004 16:04:27 +0000 (+0000) Subject: Implement slapi_entry_{get,set}_uniqueid X-Git-Tag: OPENDLAP_REL_ENG_2_2_MP~333 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f9b719f56ea52fa71c4620c0ba808723ad2693ec;p=openldap Implement slapi_entry_{get,set}_uniqueid --- diff --git a/servers/slapd/slapi/proto-slapi.h b/servers/slapd/slapi/proto-slapi.h index 9544e4acf9..eca8f2152a 100644 --- a/servers/slapd/slapi/proto-slapi.h +++ b/servers/slapd/slapi/proto-slapi.h @@ -61,6 +61,8 @@ extern int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char * extern int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value); extern int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr ); extern int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr ); +extern const char *slapi_entry_get_uniqueid( const Slapi_Entry *e ); +extern void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid ); extern int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e ); extern int slapi_entry_rdn_values_present( const Slapi_Entry *e ); extern int slapi_entry_add_rdn_values( Slapi_Entry *e ); diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 9abff75201..8c17edc3e6 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -4166,3 +4166,35 @@ int slapi_entry_add_rdn_values( Slapi_Entry *e ) #endif /* LDAP_SLAPI */ } +const char *slapi_entry_get_uniqueid( const Slapi_Entry *e ) +{ +#ifdef LDAP_SLAPI + Attribute *attr; + const char *uniqueid; + + attr = attr_find( e->e_attrs, slap_schema.si_ad_entryUUID ); + if ( attr == NULL ) { + return NULL; + } + + if ( attr->a_vals != NULL && attr->a_vals[0].bv_len != 0 ) { + return slapi_value_get_string( &attr->a_vals[0] ); + } +#endif /* LDAP_SLAPI */ + + return NULL; +} + +void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid ) +{ +#ifdef LDAP_SLAPI + struct berval bv; + + attr_delete ( &e->e_attrs, slap_schema.si_ad_entryUUID ); + + bv.bv_val = uniqueid; + bv.bv_len = strlen( uniqueid ); + attr_merge_normalize_one( e, slap_schema.si_ad_entryUUID, &bv, NULL ); +#endif /* LDAP_SLAPI */ +} +