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

need help!



I just wanna get a function like this:
int ldap_auth(char *user, char *password){
#define LDAP_SERVER	"localhost"
#define LDAP_BASEDN	"o=auth, c=ABC"
#define LDAP_UIDATTR	"mailId"
#define LDAP_FILTER     ""
#define LDAP_BIND_DN    NULL
#define LDAP_BIND_PW    NULL
...............
...............
...............
...............
if ERROR return (0);
return (1);
}

here I give user's id and password,so ldap_auth() search mailId at the
database and verify the password with Userpassword attribute, then give
the anwser.
anyone can give me a sample function,Thanks very much!

BTW:the is the test.ldif
dn: uid=test, ou=vuser, o=auth, c=ABC
uid: test
cn: test
objectClass: account
objectClass: posixAccount
objectClass: muser
objectClass: top
objectClass: shadowAccount
userPassword: {crypt}wkKQSXRgdYr8o
uidNumber: 1234
gidNumber: 1234
homeDirectory: /home/vhosts/abc.com/t/e/test
mailId: test@abc.com
mailacceptinggeneralid: test
----------------------------------------------------------------
Snofe Deng <dsnofe@hotmail.com>
----------------------------------------------------------------