lazy saunter

(personal learnings in computation)

Wednesday, June 25, 2008

login page for group members

when i first start creating web pages that needed to be restricted to certain users, i thought php sessions were the solution (they are A solution, as are sessions in perl). i had heard of the apache .htaccess file but i was head-set on using php to solve every obstacle that came up. now that i shy away from php as much as i can now, i find that the alternatives to php can offer much easier implementations in many circumstances.

not only can .htaccess files handle users and passwords that apply to just that one directory (see last post), they can also handle users that you specify and that can be authenticated against usernames and passwords on an LDAP server (this is a server that handles user accounts). if you want to restrict a web page to members of an LDAP group, you only specify the group in the .htaccess file and the username/password authentication is handled by LDAP.

here is a sample .htaccess file that accomplishes this:

AuthName "You must be in the fruitcakes group to enter"
AuthType Basic
AuthBasicProvider ldap
AuthLDAPUrl ldap://ldap.company.com:389/ou=users,dc=com
AuthzLDAPAuthoritative on
AuthLDAPGroupAttribute memberUid
AuthLDAPGroupAttributeIsDN off
require ldap-group cn=fruitcakes,ou=groups,dc=com

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home