Article View: news.software.nntp
Article #32323Re: Help. News Server w/ LDAP authentication ?
From: Keith Lewis
Date: Mon, 19 Oct 1998 00:00
Date: Mon, 19 Oct 1998 00:00
153 lines
4757 bytes
4757 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Ricardo Stella <stella@NO-SPAM.rider.edu> writes:
>Netscape's collabra, but it's not free.
>I guess somehow whatever controls nnrp.access could be hacked to
>remotely authenticate. In that case using a PERL script and PerlLDAP
>should do it.
>I asked the same question a few months ago and got no reply whatsoever.
>Jeff Baker wrote:
>> Anybody know of a decent news server that can use LDAP
>> for authentication. Please e-mail responses.
I recently wrote a small c program that links against openldap and
modified nnrpd.c to call it.
It works for me.
Steps are:
1) Get and install OpenLDAP from http://www.openldap.org/
2) Modify inn/nnrpd/nnrpd.c as follows:
#if HAVE_GETSPNAM
if ((spwd = getspnam(user)) != NULL)
pwd->pw_passwd = spwd->sp_pwdp;
#endif
if (!EQ(pwd->pw_passwd, crypt(pass, pwd->pw_passwd)))
continue;
! /* KBL Fudge - look up in ldap */
! } else if (user && EQ(fields[2], "LDAP")) {
! if ( ! ldap_pwd_ok( user, pass ) )
! continue;
! /* end of kbl fudge */
} else {
- ----------------------------------------------------------------------
3) edit the Makefile
LDFLAGS = -L/usr/local/lib
LIBS = -lldap -llber
And added ldap_pwd_ok.c to SOURCES and ldap_pwd_ok.o to OBJECTS
- ----------------------------------------------------------------------
4) copy ldapconfig.h from the OpenLDAP source into inn/nnrpd
- ----------------------------------------------------------------------
5) edit the nnrpd.access file:
## Default is no access, no way to authentication, and no groups.
*:: -no- : -no- :!*
! *:Read Post:LDAP: :*
- ----------------------------------------------------------------------
6) create ldap_pwd_ok.c
#include <strings.h>
#include <errno.h>
#include <lber.h>
#include <ldap.h>
#include "ldapconfig.h"
int ldap_pwd_ok ( char *user, char *passwd) {
char ldaphost[]="dirgod"; /* you need to parameterize this */
LDAP *ld;
LDAPMessage *res, *e;
char filter[128];
char *attrs[] = { "dn", 0 };
char *dn;
strcpy(filter,"(uid=");
strcat(filter,user);
strcat(filter,")");
if (( ld = ldap_open( ldaphost,LDAP_PORT)) == NULL ) {
perror( ldaphost );
exit( 1 );
}
/* printf( "doing an unauth bind\n"); */
if ( ldap_simple_bind_s( ld, LDAPSEARCH_BINDDN, LDAPSEARCH_BIND_CRED )
!= LDAP_SUCCESS ) {
/* ldap_perror( ld, "ldap_bind" ); */
return(0);
}
/* printf( "searching for user \n"); */
if ( ldap_search_s( ld, LDAPSEARCH_BASE, LDAP_SCOPE_SUBTREE,
filter, attrs, 0, &res)
!= LDAP_SUCCESS ) {
/* ldap_perror( ld, "ldap_usearch" ); */
return(0);
}
/* printf("getting first entry\n"); */
e = ldap_first_entry( ld, res );
if ( e == (LDAPMessage *) 0 ) {
/* ldap_perror( ld, "ldap_esearch" ); */
return(0);
}
/* printf("getting dn\n"); */
dn = ldap_get_dn( ld, e);
/* printf("dn is\n%s\n",dn); */
ldap_unbind(ld);
/* printf("unbinding\n"); */
if (( ld = ldap_open( ldaphost,LDAP_PORT)) == NULL ) {
/* perror( ldaphost ); */
return(0);
}
/* printf("doing it\n"); */
if ( ldap_simple_bind_s( ld, dn, passwd )
!= LDAP_SUCCESS ) {
/* ldap_perror( ld, "ldap_fsearch" );
printf("tough luck\n"); */
return(0);
}
return(1);
}
- ----------------------------------------------------------------------
Keith
(p.s. apologies for hadrcoding dirgod into the source...)
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2i
iQCVAwUBNivHdnEpE0nRVDfpAQGsqQP/Vm/AnlTF+EDht6pJcv6lD9oGyAN9Sehq
KW9stzfGeS2Np0lPaPE0fFMFfQwygtNTGIGUMpjty0H0ThOuH3GCUh8vbE7dKaSO
dyYqA71uhh1WhX5DegNtfIYXqdFEF8rSbrvozkAAeUTT0B5ohIgJzPZZnsmExCNv
JL5I0vV0o+Y=
=XyhF
-----END PGP SIGNATURE-----
Technical Details
Message-ID:
<70gh31$nhj$1@towncrier.cc.monash.edu.au>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<35fd50d6.19314042@news.newsguy.com> <360C07A2.7315F0E5@rider.edu>Show Full Headers
Complete Article Headers
Message-ID: <70gh31$nhj$1@towncrier.cc.monash.edu.au> Subject: Re: Help. News Server w/ LDAP authentication ? Date: Mon, 19 Oct 1998 00:00:00 +0000 From: keithl@mukluk.cc.monash.edu.au (Keith Lewis) References: <35fd50d6.19314042@news.newsguy.com> <360C07A2.7315F0E5@rider.edu> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 402993667 Distribution: world X-Complaints-To: abuse@monash.edu.au X-Trace: towncrier.cc.monash.edu.au 908838817 24115 130.194.2.37 (19 Oct 1998 23:13:37 GMT) Organization: Monash Uni NNTP-Posting-Date: 19 Oct 1998 23:13:37 GMT Newsgroups: news.software.nntp