
March 19th, 2004, 02:07 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 8
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Problem with ldap_get_values
Code:
int tam,n_error;
char buf[500],DN[500],contrassenya[500], error_l[500];
char **tmp_buf;
char *atr[]={"commonName","surname",NULL};
LDAP *tmp_resp;
LDAPMessage *res,*res_p;
...
...
...
if(tmp_resp!=NULL)
{
if((n_error=ldap_simple_bind_s(tmp_resp,DN,contrassenya))!=LDAP_SUCCESS)
{
close(sock);
printf("%s",DN);
printf("%s",contrassenya);
printf("Failure\n");
return -1;
}
else
{
tam=sprintf(buf,"Correctament Autentificat\n");
write(sock,buf,tam);
if(ldap_search_s(tmp_resp, DN, LDAP_SCOPE_BASE, "(ObjectClass=*)",
atr, 0, &res)==LDAP_SUCCESS)
{
if((res_p=ldap_first_entry(tmp_resp, res))!=NULL)
{
if((tmp_buf=(ldap_get_values(tmp_resp,res_p,(char*)&atr)))!=NULL)
{ /*Anem copiant els valors a la Taula*/
strcpy(taula_global[MAX].full_name,(char*)(&tmp_buf));
taula_global[MAX].sock_name=sock;
MAX++;
if(MAX==50)MAX=0;
printf("Usuari Afegit a Taula\n");
if(ldap_unbind(tmp_resp)==LDAP_SUCCESS)
return 0;
else
printf("Error al fer unbind\n");
}
else
printf("Error al afegir a la Taula\n");
}
else
printf("Error al Obtenir valors\n");
}
else
printf("La entrada no s'ha trobat\n");
}
}
I am doing a small job for the University and I have a problem when trying to get the values from the LDAP query I have previously done. Basically, the problem is that the function ldap_get_values returns NULL...
Any hints on what I am doing wrong ?
Thanks in Advance.
Last edited by ourumov : March 19th, 2004 at 02:11 PM.
|