[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Problems when using ldap_add_s() API call
- To: OpenLDAP <openldap-software@OpenLDAP.org>
- Subject: Problems when using ldap_add_s() API call
- From: Lucas Brasilino <brasilino@recife.pe.gov.br>
- Date: Mon, 19 Jul 2004 14:06:18 -0300
- Organization: Emprel - Empresa Municipal de Informatica
- User-agent: Mozilla/5.0 (X11; U; Linux i686; pt-BR; rv:1.4.2) Gecko/20040308
Hi
I've running in problems using ldap_add_s(). I've been searching
ml archives about this problem. The most close thread about it is:
http://www.openldap.org/lists/openldap-software/199910/msg00099.html
Well, I'm populating an LDAPMod (properly, I think) structure
and calling ldap_add_s() it returns "no values for attribute type".
But there's values to attribute!!!
Here comes the code snippet:
LDAP *ldapconn;
char *dn = "cn=logan,ou=People,dc=emprel,dc=recife";
LDAPMod *attrs[4];
int protocol;
if ((attrs[0] = (LDAPMod *)malloc (sizeof (LDAPMod *))) == NULL) exit
(2);
attrs[0]->mod_op = 0;
attrs[0]->mod_type = "objectClass";
attrs[0]->mod_values = (char **)malloc (3 * sizeof (char **));
*attrs[0]->mod_values = strdup("top");
attrs[0]->mod_values++;
*attrs[0]->mod_values = strdup("person");
attrs[0]->mod_values++;
*attrs[0]->mod_values = NULL;
if ((attrs[1] = (LDAPMod *)malloc (sizeof (LDAPMod *))) == NULL) exit
(2);
attrs[1]->mod_op = 0;
attrs[1]->mod_type = "cn";
attrs[1]->mod_values = (char **)malloc (2 * sizeof (char **));
if (attrs[1]->mod_values == NULL) exit (3);
*attrs[1]->mod_values = strdup ("logan");
if (*attrs[1]->mod_values == NULL) exit (4);
attrs[1]->mod_values++;
*attrs[1]->mod_values = NULL;
if ((attrs[2] = (LDAPMod *)malloc (sizeof (LDAPMod *))) == NULL) exit (2);
attrs[2]->mod_op = 0;
attrs[2]->mod_type = "sn";
attrs[2]->mod_values = (char **)malloc (2 * sizeof (char **));
*attrs[2]->mod_values = strdup ("wolverine");
if (*attrs[2]->mod_values == NULL) exit (4);
attrs[2]->mod_values++;
*attrs[2]->mod_values = NULL;
attrs[3] = NULL;
ldap_initialize(&ldapconn,"ldap://172.20.1.1"); /* success */
protocol = LDAP_VERSION3;
ldap_set_option (ldapconn, LDAP_OPT_PROTOCOL_VERSION, &protocol); /*
success */
ldap_simple_bind_s(ldapconn, "cn=Manager,dc=recife",
"mysecretpassword"); /* just fine */
/* here is the problem */
if (ldap_add_s (ldapconn, dn, attrs) != LDAP_SUCCESS)
{
ldap_perror(ldapconn,"ldap_add_s");
ldap_unbind(ldapconn);
exit(1);
}
So ldap_perror() prints out to stderr:
ldap_add_s: Protocol error
additional info: no values for attribute type
Any tip, recommendation or help?
thanks a lot in advance
--
[]'s
Lucas Brasilino
brasilino@recife.pe.gov.br
http://www.recife.pe.gov.br
Emprel - Empresa Municipal de Informatica (pt_BR)
Municipal Computing Enterprise (en_US)
Recife - Pernambuco - Brasil
Fone: +55-81-34167078