[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Custom tools? API Quesitons...
- To: openldap-software@OpenLDAP.org
- Subject: Custom tools? API Quesitons...
- From: Jason Gerfen <jason.gerfen@scl.utah.edu>
- Date: Fri, 16 Jul 2004 10:17:45 -0600
- Organization: Student Computing Marriott Library University of Utah
- User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3
My question is regarding using the OpenLDAP API's in linux (SuSE 9.0 to
be exact)
I have created two tools using the LDAP API, one is compiled as a binary
to do simple searches and the other is a shared object (or PAM module to
be precise) which also does simple searches.
My problem is that when I test the shared object (or PAM module) it
fails on the ldap_simple_bind() function. Below is a snippit of the
code I am using. I have tried several methods of binding to the LDAP
directory in order to search for a username with no luck, any help is
appreciated....
[Snippit]
static int _ldap_search(udataptr myUser)
{
LDAP *ld;
LDAPMessage *res, *e;
int i;
char *a, *dn;
void *ptr;
char **vals;
char buffer[80];
char errors[256];
sprintf(buffer, "(cn=%s)", myUser->usrname);
/* open a connection */
if((ld = ldap_init(dflts[7], *dflts[8])) == NULL) {
_pam_log(LOG_ERR, "Could not initialize connection");
} else {
_pam_log(LOG_ERR, "Connection initialized");
/* authenticate as nobody */
if(ldap_simple_bind_s(ld, dflts[11], dflts[12]) != LDAP_SUCCESS)
{ // it fails here
_pam_log(LOG_ERR, "Couldn't bind to LDAP");
} else {
_pam_log(LOG_ERR, "Bind to LDAP successful");
if(ldap_search_s(ld, dflts[10], LDAP_SCOPE_SUBTREE,
buffer, NULL, 0, &res) != LDAP_SUCCESS ) {
_pam_log(LOG_ERR, "LDAP Search failed");
} else {
_pam_log(LOG_ERR, "LDAP Search succeeded"); }
}
[/Snippit]
This is being compiled with the following makefile
Makefile:
CC=gcc
CFLAGS=-fPIC
LDFLAGS=-x --shared
LIBS=-lnsl -lpam -lldap -lc
SRCS=lame.c
OBJS=lame.o
LIBSHARED=pam_looser.so
LIBCONF=looser.conf
SECUREDIRECTORY=/lib/security
CONFDIR=/etc
CONFMODE=700
SECUREMODE=755
INSTALL=install
all: $(LIBSHARED)
install: all
$(INSTALL) -m $(SECUREMODE) $(LIBSHARED) $(SECUREDIRECTORY);
$(INSTALL) -m $(CONFMODE) $(LIBCONF) $(CONFDIR);
$(LIBSHARED): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $? $(LIBS)
$(OBJS): $(SRCS)
$(CC) $(CFLAGS) -o $@ -c $*.c
clean:
rm -f $(OBJS) $(LIBSHARED) a.out core *~
I hope someone on this list (tell me if this is the correct list to post
questions of this type to) that can help me get this working... as I
said the above code compiled as a shared object (PAM module) will not
work but it does work when compiled as a simple static binary.
--
Jason Gerfen
Student Computing Group
Marriott Library
University of Utah
(801) 585-9810
jason.Gerfen@scl.utah.edu
"...Sometimes I just yell at myself. And it
makes me sad, sometimes I make myself cry..."
~ My nephew Dawsyn