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

Create openldap user's password with sasl



Thanks for all who had answer my question
about "slapd.conf and sasl"
 
at last,for using sasl with openldap2.11
i config the slapd.conf like this:
#######################################################################
# part of slapd.conf
...
require SASL
sasl-host "example.com"
sasl-realm "example.com"
database ldbm
suffix  "dc=example, dc=com"
directory ./db
rootdn  "cn=root, dc=example, dc=com"
rootpw  secret
index  objectclass eq
index  uid pres,eq,sub
index  cn,sn pres,eq,sub,subany
dbnosync
dbnolocking
 
....
#
#######################################################################
 
when i start slapd.exe,i find cann't login as "cn=root, dc=example, dc=com"
with password "secret".
 
so i add a user named "root" with saslpwd.exe , set it passwd as "111"
but i can't login it,my c source to login i like this
#######################################################################
#C source to login openldap
    berval *cred;
    cred=(berval *)malloc(sizeof(berval));
    cred->bv_len=strlen(password);
    cred->bv_val=(char *)malloc(sizeof(char)*(strlen(password)+1));
    strcpy(cred->bv_val,password);
    int ss;
    ss=ldap_sasl_bind (
      ld,
      loginDN,
      "CRAM",
      cred,
      NULL,
      NULL,
      &rc  );
#
#####################################################################
 
Notice:
if i replace the code with
    rc = ldap_simple_bind_s( ld, loginDN, password );
and remove sasl declaration from slapd.conf,
i can login as "cn=root, dc=example, dc=com"
with password "secret".
 
what's wrong with me?
 
 
Best Regard!
sheujun