[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
RE: Question regarding Search when BASE=NULL
Hi Bruno Thanks,
But when LDAP search can search with NULL parameter
why can't I do using the base as NULL.
If someone else also looks at this mail, please look
at the mail below, along with the code snippet.
Purpose:
> I tried to write a search program using C pasted in
> the end of the mail. What I intended is that I just
> pass the IP and read the server DN using the
> response
> message.
regards,
Bhishm
--- Bruno Lopes de Souza Benchimol
<brunobenchimol@terra.com.br> wrote:
> Ldapsearch uses ldap.conf (/etc/ldap , or wherever
> you've put it), that's
> why u cant search it, u must pass the base, so he
> doesn't know WHERE to
> search for it, its need a start point, got it? Hope
> so, if you want some
> help code you can take a look at squid package which
> has a ldap auth code
> into contrib. if im not wrong, well that's the only
> place that I can
> remember to find out a C code using ldap.
>
> That's all hope thats help.
>
>
>
> -----Original Message-----
> From: owner-openldap-software@OpenLDAP.org
> [mailto:owner-openldap-software@OpenLDAP.org] On
> Behalf Of Bhishm Sharma
> Sent: Thursday, September 16, 2004 10:46 AM
> To: openldap-software@OpenLDAP.org
> Subject: Newbie Question regarding Search API's
>
> Hi,
>
> I tried to write a search program using C pasted in
> the end of the mail. What I intended is that I just
> pass the IP and read the server DN using the
> response
> message.
>
> Here are the scenarios and result:
> i) Tried to connect to AD (Active Directory)using
> Prog
> Search Results:
> - Referral is returned when openldap server is not
> running on local machine. DOn't Know why?
> - Local LDAP servers DN is returned when openldap is
> running on local machine. DOn't Know why?
>
> ii) Tried to connect another LDAP Server running
> OpenLDAP
> Search Result:
> - No such Object
>
>
> Please guide me or show me the path how to move
> forward. Why the above behavior is coming and how to
> handle the referral or "No such object" to move
> forward.
>
>
> Few things to note in the code:
> i) Anonymous Bind
> ii) In ldap_search_s, I am passing Base as NULL i.e.
>
ldap_search_s(ld,NULL,LDAP_SCOPE_SUBTREE,"objectClass=*",NULL,0,&resul)
>
> When I am using the "ldapsearch" command its working
> fine. I didn't pass the Base and it shows me the
> entry
> but when I am using the search API's I don't know
> how
> to do it.
>
>
> CODE SNIPPET:
> -----------
>
> protocolVersion= LDAP_VERSION3;
>
>
>
if((result=ldap_set_option(ld,LDAP_OPT_REFERRALS,LDAP_OPT_OFF))==
> -1)
> {
> printf("%s\n",ldap_err2string(result));
> return(2);
> }
> printf("Successfully set referrals\n");
>
> result =
>
ldap_set_option(ld,LDAP_OPT_PROTOCOL_VERSION,&protocolVersion);
>
> printf("Verison: %d\n",LDAP_VERSION3);
>
> //BIND OPERATION
>
if((result=ldap_simple_bind_s(ld,NULL,NULL))!=LDAP_SUCCESS)
> {
> printf("Error in ldap_simple_bind_s:-
> %s\n",ldap_err2string(result));
> return(2);
> }
> printf("LDAP Result:-
> %s\n",ldap_err2string(result));
>
> //Search Through the tree
>
if((result=ldap_search_s(ld,NULL,LDAP_SCOPE_SUBTREE,"objectClass=*",NULL,0,&
> resul))!=LDAP_SUCCESS)
> {
> printf("lDAP Search:-
> %s\n",ldap_err2string(result));
> // result =
> ber_printf(ber,"t{V}",LDAP_TAG_REFERRAL,resul);
> printf("RESULT AGAIN:-
> %d\n",ldap_count_references(ld,resul));
> if(result == LDAP_REFERRAL)
> {
> printf("REferral Returned\n");
> }
> // return(2);
> }
>
> printf("LDAP Search Result:-
> %s\n",ldap_err2string(result));
> printf("Number of Entries Returned:-
> %d\n",ldap_count_entries(ld,resul));
>
>
for(entry=ldap_first_entry(ld,resul);entry!=NULL;entry=ldap_next_entry(ld,en
> try))
>
>
> THANKS & REGARDS,
> BHISHM
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail
>
> Esta mensagem foi verificada pelo E-mail Protegido
> Terra.
> Scan engine: VirusScan / Atualizado em 15/09/2004 /
> Versco: 1.5.2
> Proteja o seu e-mail Terra:
> http://www.emailprotegido.terra.com.br/
>
>
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail