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

Antwort: OpenLDAP API



I tested the short program and it worked for me by modifying the base_dn
and the search filter.
Perhaps your ACL is so strong not to allow a anoymous simple bind.#
Have you runed on debugging or other logging style ?
You should supply a username and password to bind as manager or anything
else.

My ldap_simple_bind:
rc = ldap_simple_bind_s(ldi, "cn=Manager,dc=mainwork,dc=nw", "secure");

My filter:
char *filter = "uid=Admin*";

Output:
DN: uid=Admin,ou=Admins,ou=Mainhost01,o=mainwork information technology
AG,dc=mainwork,dc=nw


Rgds Franz



____________________________________________________
Franz Skale
mainwork information technology AG
IT-Services
Tech Gate Vienna
Donaucitystrasse 1
A-1220 Wien
Tel: +43 1 333 48 58-0
Fax: +43 1 333 48 58-24
e-mail: f.skale@mainwork.com
Internet: http://www.mainwork.com


                                                                                                                                 
                    Igor Brezac                                                                                                  
                    <igor@ipass.net>                  An:     <OpenLdap-Software@OpenLDAP.com>                                   
                    Gesendet von:                     Kopie:                                                                     
                    owner-openldap-software@Op        Thema:  OpenLDAP API                                                       
                    enLDAP.org                                                                                                   
                                                                                                                                 
                                                                                                                                 
                    01.04.2002 16:56                                                                                             
                                                                                                                                 
                                                                                                                                 





I apologize for the duplicate message, I forgot to use the subject line.

Hello,

I use Solaris 8 and openldap 2.0.23.  The following short program crashes
on the ldap_unbind() call.  I tried various different versions of this
program without success.  Am I doing something wrong here?

Your help will be greatly appreciated.

-Igor

#include        <sys/types.h>
#include        <stdlib.h>

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

int main() {

        int rc;
        LDAP   *ldi;
        struct timeval tv;
        LDAPMessage *res = NULL;
        LDAPMessage *msg = NULL;
        char *dn;
        char *server = "ldap://10.1.1.197/";;
        char *base_dn = "o=pb";
        char *filter = "uid=igor";
        char *attrs[] = {"dn",NULL};


        rc = ldap_initialize(&ldi, server);
        if (rc != LDAP_SUCCESS) {
                exit (2);
        }

        rc = ldap_simple_bind_s(ldi, "", "");
        if (rc != LDAP_SUCCESS) {
                exit (2);
        }

//  If the ldap server is no longer available at this point

        tv.tv_sec = 5;
        tv.tv_usec = 0;
        rc = ldap_search_st(ldi, base_dn, LDAP_SCOPE_SUBTREE, filter,
                        (char **) attrs, 0, &tv, &res);

        if (rc != LDAP_SUCCESS) {
                ldap_get_option(ldi, LDAP_OPT_ERROR_NUMBER, &rc);
                printf("ldap_search_st() error %s\n", ldap_err2string(rc));
                ldap_msgfree(res);
                ldap_unbind(ldi);

// ldap_unbind will cause a dump here

                exit(2);
        }

        msg = ldap_first_entry(ldi, res);
        dn = ldap_get_dn(ldi, msg);
        printf("DN: %s\n", dn);

        ldap_msgfree(msg);
        free(dn);
        ldap_unbind_s(ldi);
        exit (1);
}