간단한 웹 기반 디렉토리 탐색/관리 응용 프로그램을 구축하려고합니다.영구 LDAP 인증 세션
응용 프로그램 요구 사항 :
- 는 Active Directory (또는 다른 디렉터리 서비스) 도메인 사용자 액세스 이 웹 응용 프로그램과 같은 도메인 사용자/암호 자격 증명으로 로그인합니다.
- 그런 다음 사용자가 등등/편집 항목, 편집 항목의 속성을 만들고,
을 디렉토리 트리를 탐색 할 수 있습니다 나는 펄 인터넷을 사용하고 있습니다 : LDAP를 LDAP 작업을 위해, 같이 :
#!/usr/bin/perl -wT
use Net::LDAP;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $ssl = 1;
my $srv = '192.168.56.110';
my $uri = $ssl ? 'ldaps://' : 'ldap://';
my $c = Net::LDAP->new($uri . $srv) or
die "Unable to connect to server: [email protected]\n";
# !!! This is a temporary workaround !!!
my $binddn = "cn=Administrator,cn=users,dc=example,dc=com";
my $passwd = "password";
my $mesg = $c->bind($binddn, password => $passwd);
die 'Unable to bind: ' . $mesg->error . "\n" if $mesg->code;
# DN to be deleted
my $dn = param('DN');
$mesg = $c->delete($dn);
die 'Error in delete: '. $mesg->error() ."\n" if $mesg->code();
$c->unbind;
전에서와 같이 HTML 양식이 CGI 스크립트를 호출 할 수
<form action="/cgi-bin/del.cgi" method="post">
<br>Peter Parker
<input type="radio" name="DN"
value="cn=peter parker,cn=users,dc=example,dc=com">
<br>Clark Kent
<input type="radio" name="DN"
value="cn=clark kent,cn=users,dc=example,dc=com">
<br>
<input type="submit" value="Delete User">
</form>
이 코드의 문제는 LDAP 작업이 ADMI을 사용하는 것입니다 웹 응용 프로그램을 실행하는 사용자의 자격 증명이 아닌 매번 사용자에게 자격 증명을 요청할 수 없기 때문에이 해결 방법을 사용하고 있습니다. 사용자 인증을 유지하는 방법을 모르겠습니다.
내 웹 응용 프로그램 그는의 자격 증명을 묻는와 같이 디렉토리 서비스에 바인드 요청을 발행, LDAP를 통해 사용자를 인증: 그 후
...
# read user supplied credentials
my $user_id = param('user_id');
my $password = param('password');
# now find the DN of user_id in directory
my $ssl = 1;
my $srv = '192.168.56.110';
my $uri = $ssl ? 'ldaps://' : 'ldap://';
my $c = Net::LDAP->new($uri . $srv) or
die "Unable to connect to server: [email protected]";
# admin credentials are needed here to find the user DN
my $rootdn = "cn=Administrator,cn=users,dc=example,dc=com";
my $rootpw = "secret";
my $mesg = $c->bind($rootdn, password => $rootpw);
die "Unable to bind: ". $mesg->error if $mesg->code;
$mesg = $c->search(
base => 'dc=example,dc=com',
scope => 'sub',
filter => "(&(objectClass=user)(sAMAccountName=$user_id))",
attrs => ['sAMAccountName'],
);
die "Bad search: ". $mesg->error() if $mesg->code();
my ($entry) = $mesg->entries;
die "User not found: $user_id\n" unless $entry;
my $dn = $entry->dn;
# User DN found.. now check the credentials
$mesg = $c->bind($dn, password => $password);
die "Unable to bind: ". $mesg->error if $mesg->code;
$c->unbind();
# credentials validated!
print header, start_html('Welcome!'), h1('Hello, YOU!'), end_html;
이 쿠키는 웹을 시작하는 사용자의 브라우저로 전송됩니다 세션. 필자는 필요할 때마다 사용자 자격 증명을 데이터베이스에 보관 한 다음 del.cgi (및 기타 유사한 스크립트)에 전달할 수 있지만 좋은 보안 관행은 아니라고 생각합니다.
웹 세션이 활성화되어있는 동안 영구적 인 LDAP 인증 세션을 유지하려면 어떻게해야합니까?