[Date Prev][Date Next] [Chronological] [Thread] [Top]

ldap_modify Problem (ITS#364)



Hi there,

I have a problem with the C API function ldap_modify, maybe it is trivial but I
can`t figure it out. i get no error-messages, but nothing will be modified...
I am sorry, maybe I didn`t understand the "dn". 

Thanks a lot.

klinki

here is my little programm:

#include <stdlib.h>
#include <lber.h>
#include <ldap.h>

#define ROOTDN  "cn=admin, dc=uni-tuebingen, dc=de"
#define PASSWD  "secret"
#define HOST    "localhost"
#define PORT    1099

main() {
  LDAP *ld;
  LDAPMod *list_of_attrs[4];
  LDAPMod attribute1, attribute2, attribute3;
  LDAPMessage *result;
  int msgid;

  char *dn = "uid=444, dc=uni-tuebingen,dc=de";

  char *homePhone_values[] = { "Bill Gates", 0 };
  char *telephoneNumber_values[] = { "869-5309", 0 };


  /*  Verbinden   */
  if ( (ld = ldap_open(HOST,PORT)) == 0)
    exit(1);
  printf("connecting to ldap server ...\n");

  /*  Autentifikation */
  if ( ldap_simple_bind_s(ld, ROOTDN, PASSWD) != LDAP_SUCCESS)
    exit(1);
  printf("bind ...\n");



  /* beispiel Veraenderung */
  attribute1.mod_type = "description";
  attribute1.mod_op = LDAP_MOD_ADD;
  attribute1.mod_values = homePhone_values;
                                                                    


  attribute2.mod_type = "telephoneNumber";
  attribute2.mod_op = LDAP_MOD_REPLACE;
  attribute2.mod_values = telephoneNumber_values;

  attribute3.mod_type = "owner";
  attribute3.mod_op = LDAP_MOD_DELETE;
  attribute3.mod_values = 0;
  /* NOTE: When removing attributes, you need to specify a NULL value for the mod_values field. */






  /* Add the pointers to these LDAPMod structures to an array. */
  list_of_attrs[0] = &attribute1;
  list_of_attrs[1] = &attribute2;
  list_of_attrs[2] = &attribute3;
  list_of_attrs[3] = 0;



  /* Change the entry. */
        ldap_modify(ld,dn,list_of_attrs);
printf("habs gemacht\n");
    /* exit(1);  */
  if ( ( msgid = ldap_modify( ld, dn, list_of_attrs ) ) == -1 ) {
    printf("hier noch nicht\n");
    ldap_perror( ld, "ldap_modify" );
    printf(" scheisse, gab ein Fehler ... \n");
    return( 1 );
  }
  printf("loese die Verbindung jetzt\n");
  ldap_unbind(ld);
}


and this is the entry:


dn:  uid=444, dc=uni-tuebingen,dc=de
objectclass: organizationalUnit
uid: 444
ou: Kipfenberg 444
telephonenumber: 444 444 444
postalcode: 85110
l: Kipfenberg
streetadress: Frankenring 4
owner: Fam. Josef u. Beate Neumeyer          


This entry shoud be changed to:

description: bill Gates
 elephonenumber: 869-5309
and owner should be removed???

thnx a lot.