shelldap
changeset 93 4c7843b9a047
parent 92 a1aa55019077
child 94 4464f9984530
equal deleted inserted replaced
92:a1aa55019077 93:4c7843b9a047
   459 	LDAP_BUSY
   459 	LDAP_BUSY
   460 	LDAP_UNAVAILABLE
   460 	LDAP_UNAVAILABLE
   461 	LDAP_OTHER
   461 	LDAP_OTHER
   462 	LDAP_TIMEOUT
   462 	LDAP_TIMEOUT
   463 	LDAP_NO_MEMORY
   463 	LDAP_NO_MEMORY
       
   464 	LDAP_EXTENSION_PASSWORD_MODIFY
   464 	LDAP_CONNECT_ERROR
   465 	LDAP_CONNECT_ERROR
   465 	LDAP_CONTROL_PAGED /;
   466 	LDAP_CONTROL_PAGED /;
   466 use Net::LDAP::Util qw/ canonical_dn ldap_explode_dn /;
   467 use Net::LDAP::Util qw/ canonical_dn ldap_explode_dn /;
   467 use Net::LDAP::LDIF;
   468 use Net::LDAP::LDIF;
   468 use Net::LDAP::Extension::SetPassword;
   469 use Net::LDAP::Extension::SetPassword;
   471 use File::Temp;
   472 use File::Temp;
   472 use Algorithm::Diff;
   473 use Algorithm::Diff;
   473 use Carp 'confess';
   474 use Carp 'confess';
   474 use base 'Term::Shell';
   475 use base 'Term::Shell';
   475 
   476 
       
   477 
   476 my $conf = $main::conf;
   478 my $conf = $main::conf;
   477 
   479 
   478 # make 'die' backtrace in debug mode
   480 # make 'die' backtrace in debug mode
   479 $SIG{'__DIE__'} = \&Carp::confess if $conf->{'debug'};
   481 $SIG{'__DIE__'} = \&Carp::confess if $conf->{'debug'};
   480 
   482 
   524 	}
   526 	}
   525 
   527 
   526 	# check for the pagination extension on the server early, and bail
   528 	# check for the pagination extension on the server early, and bail
   527 	# if necessary.
   529 	# if necessary.
   528 	if ( $conf->{'paginate'} && $conf->{'paginate'} =~ /^\d+$/ && $conf->{'paginate'} > 0 ) {
   530 	if ( $conf->{'paginate'} && $conf->{'paginate'} =~ /^\d+$/ && $conf->{'paginate'} > 0 ) {
   529 		my $has_pagination = ( grep $_ eq LDAP_CONTROL_PAGED, $self->{'root_dse'}->get_value('supportedControl') );
   531 		unless ( $self->{'root_dse'}->supported_control(LDAP_CONTROL_PAGED) ) {
   530 		die "Server pagination is enabled, but the server doesn't seem to support it.\n" unless $has_pagination;
   532 			die "Server pagination is enabled, but the server doesn't seem to support it.\n";
       
   533 		}
   531 	}
   534 	}
   532 	else {
   535 	else {
   533 		$conf->{'paginate'} = undef;
   536 		$conf->{'paginate'} = undef;
   534 	}
   537 	}
   535 
   538 
  2169 	my $self = shift;
  2172 	my $self = shift;
  2170 	my $dn   = shift || $self->base();
  2173 	my $dn   = shift || $self->base();
  2171 
  2174 
  2172 	$self->{'root_dse'} ||= $self->ldap->root_dse();
  2175 	$self->{'root_dse'} ||= $self->ldap->root_dse();
  2173 
  2176 
  2174 	my $pw_extension = '1.3.6.1.4.1.4203.1.11.1';
  2177 	unless ( $self->{'root_dse'}->supported_extension(LDAP_EXTENSION_PASSWORD_MODIFY) ) {
  2175 	unless ( $self->{'root_dse'}->supported_extension( $pw_extension ) ) {
       
  2176 		print "Sorry, password changes not supported by LDAP server.\n";
  2178 		print "Sorry, password changes not supported by LDAP server.\n";
  2177 		return;
  2179 		return;
  2178 	}
  2180 	}
  2179 
  2181 
  2180 	# convert given path to DN
  2182 	# convert given path to DN