~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to web/src/alpined.d/ldap.c

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2010-10-03 15:31:55 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101003153155-2exypc96j1e8tw0p
Tags: 2.02-1
* New upstream release, based on re-alpine project
* Updated debian/copyright to reflect this fact
* re-alpine removed the non-free from the tarball, so now
  we do not repack the upstream tarball. (Yay!)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#if !defined(lint) && !defined(DOS)
2
 
static char rcsid[] = "$Id: ldap.c 1006 2008-03-21 21:31:58Z hubert@u.washington.edu $";
 
2
static char rcsid[] = "$Id: ldap.c 1266 2009-07-14 18:39:12Z hubert@u.washington.edu $";
3
3
#endif
4
4
 
5
5
/* ========================================================================
54
54
            got_n_entries++;
55
55
        }
56
56
    }
57
 
    if(style == DisplayIfTwo && got_n_entries < 2){
58
 
        if(got_n_entries == 0){
59
 
          retval = -3;
60
 
        }
61
 
        else {
62
 
            for(a = ldap_first_attribute(tmp_rl->ld, tmp_e, &ber);
63
 
                a != NULL;
64
 
                a = ldap_next_attribute(tmp_rl->ld, tmp_e, ber)){
65
 
                if(strcmp(a, tmp_rl->info_used->mailattr) == 0){
66
 
                    mail = ldap_get_values(tmp_rl->ld, tmp_e, a);
67
 
                    break;
68
 
                }
69
 
            }
70
 
            if(mail && mail[0] && mail[0][0]){
71
 
                retval = 0;
72
 
                if(result){
73
 
                    (*result) =
74
 
                      (LDAP_CHOOSE_S *)fs_get(sizeof(LDAP_CHOOSE_S));
75
 
                    (*result)->ld    = tmp_rl->ld;
76
 
                    (*result)->selected_entry   = tmp_e;
77
 
                    (*result)->info_used = tmp_rl->info_used;
78
 
                    (*result)->serv  = tmp_rl->serv;
79
 
                }
80
 
            }
81
 
            else{
82
 
              retval = -2;
83
 
            }
 
57
    if(got_n_entries == 1){
 
58
        for(a = ldap_first_attribute(tmp_rl->ld, tmp_e, &ber);
 
59
            a != NULL;
 
60
            a = ldap_next_attribute(tmp_rl->ld, tmp_e, ber)){
 
61
            if(strcmp(a, tmp_rl->info_used->mailattr) == 0){
 
62
                mail = ldap_get_values(tmp_rl->ld, tmp_e, a);
 
63
                break;
 
64
            }
 
65
        }
 
66
        if(mail && mail[0] && mail[0][0]){
 
67
            retval = 0;
 
68
            if(result){
 
69
                (*result) =
 
70
                  (LDAP_CHOOSE_S *)fs_get(sizeof(LDAP_CHOOSE_S));
 
71
                (*result)->ld    = tmp_rl->ld;
 
72
                (*result)->selected_entry   = tmp_e;
 
73
                (*result)->info_used = tmp_rl->info_used;
 
74
                (*result)->serv  = tmp_rl->serv;
 
75
            }
 
76
        }
 
77
        else{
 
78
            retval = -2;
84
79
        }
85
80
    }
86
 
    else if(got_n_entries == 0)
 
81
    else
87
82
      retval = -3;
88
 
    else{
89
 
        WPLDAPRES_S *new_ldap_sl, *tmp_ldap_sl;
90
 
 
91
 
        new_ldap_sl = (WPLDAPRES_S *)fs_get(sizeof(WPLDAPRES_S));
92
 
        new_ldap_sl->next = NULL;
93
 
        new_ldap_sl->reslist = ac->res_head;
94
 
        new_ldap_sl->str = cpystr(srchstr);
95
 
        if(wpldap_global->ldap_search_list == NULL){
96
 
            wpldap_global->ldap_search_list = new_ldap_sl;
97
 
        }
98
 
        else{
99
 
            for(tmp_ldap_sl = wpldap_global->ldap_search_list;
100
 
                tmp_ldap_sl->next; tmp_ldap_sl = tmp_ldap_sl->next);
101
 
            tmp_ldap_sl->next = new_ldap_sl;
102
 
        }
103
 
        retval = -5;
104
 
    }
105
 
    dprint((7, "calling ldap_addr_select, returning(%d)", retval));
106
83
 
107
84
    return(retval);
108
85
}