perl-ldap

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

* Control/Subentries.pm: new
* Constant.pm: add tags to allow exporting groups of constants
* Constant.pm: add Active Directory Control & Extension OIDs
* Constant.pm: add references to perl-ldap's modules

Bug Fixes
* META.json: update author & bugtracker
* Control/*.pm: typo & grammar fixes
* Control/Relax.pm: slight rephrasing
* FAQ.pod: fix spelling/grammar error
* Changes: fix typo

0.67 -- Sat Dec 26 14:50:55 CEST 2020

Enhancements
* Makefile.PL: update author & bugtracker
* LDIF.pm: support controls when reading
* Control/TreeDelete.pm: new
* Entry.pm: new option 'nooptions' for get_value()
* various typo fixes

SIGNATURE  view on Meta::CPAN


It will check each file's integrity, as well as the signature's
validity.  If "==> Signature verified OK! <==" is not displayed,
the distribution may already have been compromised, and you should
not run its Makefile.PL or Build.PL.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

SHA256 f5284afc11107d124adcf45144cd1b87011d11983f41991a428c9c5d14ad174a CREDITS
SHA256 5b2d51405f97f89f59fc07dfc8ff637fbd17910d4f161d379bf8e5df216d66ba Changes
SHA256 d694b58de713bc5bdf89337af5a9fd2e5b1c010e658f08572d938bd304c664f0 INSTALL
SHA256 2cf986c63fbeac4e1e7c9542449775f7fe26e6c9824d325a30d740a8f57874b9 MANIFEST
SHA256 82a36cb44769f6ee6b79dac64fc35375054b68a1c50c06bae1429a65a5271fe0 MANIFEST.SKIP
SHA256 97dcd3bb488ce648313a2202f2d367e1848bdfac1cf877bddc80975828950db8 META.json
SHA256 ab6e2a419bcfd7e107119d89027bb7f8d190b8decb91051888bdb2df69db438c Makefile.PL
SHA256 8d1471c205325b0f6e7e295a3cd8fdc42d2d76ae58fd7601c3c9f8f9329d5269 README
SHA256 e117a440799c250d2bdfb7afda4be25b55e810b67813a78497b7baf4c4f9a0fb TODO
SHA256 5f41e639a54329e4a28d6505e968d6311c95bb30f212052cd6b2fba2ea923f5e bin/ldapdelete
SHA256 8f2c3e0df1a956b84a6f574c4a15d530a6db64cf8d70b52d6e3878c6b9ff4e5a bin/ldapmodrdn
SHA256 6efb042d21c435cd13050491057f2ae54ae321ee0fcf6b2c9f52a060a93ca5e1 bin/ldapsearch

contrib/README  view on Meta::CPAN


The files in this directory are

  tklkup	  A Perl/Tk script to do LDAP directory lookups
  dot.tklkup	  Control file for tklkup
  printMembers.pl Print all members of a group (does recursive evaluation)
  isMember.pl     Determine if a given user is a member of a given group
  jpegDisplay.pl  Display JPEG photos from an LDAP directory
  jpegLoad.pl     Load JPEG photos into an LDAP directory entry
  ldapmodify.pl   A (simplified) ldapmodify clone written in Perl
  ldifdiff.pl     Generate LDIF change diff between two sorted LDIF files
  ldifsort.pl	  Sort an LDIF file by the specified key attribute.
  ldifuniq.pl	  Cull unique entries from a reference file with
                  respect to a comparison file.
  LWPsearch.pl    A sample application to show the usage of LWP::Protocol::LDAP
  recursive-ldap-delete.pl  Recursively delete a branch in an LDAP directory
  schema2ad.pl    convert standard LDAP schema into a format that AD can digest
  simple-proxy.pl A simple LDAP proxy which can act as a man-in-the-middle

Most files contain a POD with full description and author contacts.
e.g.

contrib/isMember.pl  view on Meta::CPAN



#Mark Wilcox mark@mjwilcox.com
#
#first version: August 8, 1999
#second version: August 15, 1999

#bugs: none ;)
#

#To Do: Change this into a module for Net::LDAP??
#       Add ability to handle various group objectclasses

use strict;
use Carp;
use Net::LDAP;
use URI;
use vars qw($opt_h $opt_p $opt_D $opt_w $opt_b $opt_n $opt_u );
use Getopt::Std;


contrib/ldapmodify.pl  view on Meta::CPAN


use vars qw(%opt);
use strict;

getopts('acD:e:f:h:p:P:w:', \%opt);
$opt{h} ||= 'localhost';
my $conn = Net::LDAP->new($opt{h}) or die "$opt{h}: $!\n";
my $result = $conn->bind($opt{D}, password => $opt{w});
$result->code && die("$opt{h}: bind: ", $result->error, "\n");
my $ldif = Net::LDAP::LDIF->new($opt{f}, "r");
$ldif->{changetype} = 'add' if $opt{a};
my $ldiferr;

while (my $change = $ldif->read_entry()) {
	print "dn: ", $change->dn, "\n";
	my $result = $change->update($conn);
	if ($result->code) {
		print STDERR "ldapmodify: ", $result->error, "\n";
		if ($opt{e}) {
			if (!$ldiferr) {
				$ldiferr = Net::LDAP::LDIF->new($opt{e}, 'a', change => 1)
					or die "$opt{e}: $!\n";
			}
			print { $ldiferr->{fh} } "# Error: ", $result->error;
			$ldiferr->write_entry($change);
			print { $ldiferr->{fh} } "\n";
		}
		last unless $opt{c};
	}
	print "\n";
}

=head1 AUTHOR

Kartik Subbarao <subbarao@computer.org>

contrib/ldifdiff.pl  view on Meta::CPAN

#! /usr/bin/perl

=head1 NAME

ldifdiff.pl -- Generates LDIF change diff between two sorted LDIF files.

=head1 DESCRIPTION

ldifdiff.pl takes as input two sorted LDIF files, source and target, and
generates on standard output the LDIF changes needed to transform the target
into the source.

=head1 SYNOPSIS

ldifdiff.pl B<-k|--keyattr keyattr> [B<-a|--sourceattrs attr1,attr2,...>] [B<-c|--ciscmp attr1,...>] [B<-n|--numcmp attr1,...>] [B<--dnattrs attr1,...>] [B<--sharedattrs attr1,...>] B<sourcefile> B<targetfile>

=head1 OPTIONS

=over 4

contrib/printMembers.pl  view on Meta::CPAN


     print "\nMembers of group: $dn\n";

     #returns an array reference
     my $values = $entry->get_value("uniquemember", asref => 1);

     foreach my $val (@{$values})
     {
       my $isGroup = 0; #lets us know if the entry is also a group, default no

       #change val variable to attribute

       #now get entry of each member
       #is a bit more efficient since we use the DN of the member
       #as our search base, greatly reducing the number of entries we
       #must search through for a match to 1 :)

       my @entryAttrs = ["objectclass","memberurl",$attr];

       $mesg = $ldap->search(
               base => $val,

contrib/schema2ad.pl  view on Meta::CPAN

print $ldifhandle <<EOT;
# ===============================================================================
#  This file should be imported using the following command:
#    ldifde -i -f schema-sync.ldf -v -c DC=X DC=<forest root> -j <directory path>
# ===============================================================================

EOT

# create LDAP pointing to the intermediate file handle
# this is necessary as we want to post-process the generated ldif data
my $ldif = Net::LDAP::LDIF->new($ldifhandle,"w", change => 1, wrap => 0, version => 1)
  or die 'Unable to create LDIF object'."\n";


# loop over all attribute types
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms675578.aspx
foreach my $at ($schema->all_attributes) {
  my $cn = $at->{name};
  my $syntax = $schema->attribute_syntax_oid($cn);

  die "Syntax not known for attribute $cn\n"

contrib/tklkup  view on Meta::CPAN

#
# Create process accept button
#
$Global{'sbWindow'}->Button( -text => "ACCEPT SELECTED DN", -command => \&sbaccept,
           -font => $Global{'Font'}, -borderwidth => 3 )
           -> pack(-side => "bottom", -padx => 5, -pady => 5 ) ;

#
# Create process cancel button
#
$Global{'sbWindow'}->Button(-text => "CANCEL BASE CHANGE",
           -command => \&sbcancel,
           -font => $Global{'Font'}, -borderwidth => 3)
           -> pack(-side => "top", -padx => 5, -pady => 5 ) ;

my $sbdnframe = $Global{'sbWindow'}->Frame()
      ->pack( -fill => "both", -side => "top", -padx => 5, -pady => 5 );

$Global{sbtree} = $sbdnframe->Scrolled("Tree",
                -width => 50,
                -height => 20,

data/00-cmp2.ldif  view on Meta::CPAN

counting: two
counting: three
first: 1
first: 2
first: 3
second: a
second: b
second: c

dn: o=University of Michigan, c=US
changetype: modify
delete: objectclass
-
delete: o
o: UM
-
add: counting
counting: one
counting: two
counting: three
-

data/10-in.ldif  view on Meta::CPAN


dn: o=University of Michigan, c=US
control: 2.16.840.1.113730.3.4.2 true
control: 2.16.840.1.113730.3.4.18 true:: ZG46Y249SMOkZ2FyLG91PXBlb3BsZSxvPW15b
 3JnLmNvbQ==
changetype: add
objectclass: top
objectclass: organization
objectclass: domainRelatedObject
objectclass: quipuObject
objectclass: quipuNonLeafObject
l: Ann Arbor, Michigan
st: Michigan
streetaddress: 535 West William St.
o: University of Michigan
o: UMICH

data/cosine.schema  view on Meta::CPAN

	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )

## missing from RFC1274
## incorrect syntax?
attributetype ( 0.9.2342.19200300.100.1.27 NAME 'mDRecord'
	EQUALITY caseIgnoreIA5Match
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )

# 9.3.23.  MX Record
#
#  The MX Record attribute type specifies a type MX (Mail Exchange) DNS
#  resource record [6] [7].
#
#    mXRecord ATTRIBUTE
#        WITH ATTRIBUTE-SYNTAX
#            DNSRecordSyntax
#    ::= {pilotAttributeType 28}
#
## incorrect syntax!!
attributetype ( 0.9.2342.19200300.100.1.28 NAME 'mXRecord'
	EQUALITY caseIgnoreIA5Match

lib/Net/LDAP.pm  view on Meta::CPAN

  my $control = $arg->{control}
    and $ldap->{net_ldap_version} < 3
    and return _error($ldap, $mesg, LDAP_PARAM_ERROR, 'Controls require LDAPv3');

  my $dn = $arg->{dn}
    or return _error($ldap, $mesg, LDAP_PARAM_ERROR, 'No DN specified');

  my @ops;
  my $opcode;

  if (exists $arg->{changes}) {
    my $opcode;
    my $j = 0;
    while ($j < @{$arg->{changes}}) {
      return _error($ldap, $mesg, LDAP_PARAM_ERROR, "Bad change type '" . $arg->{changes}[--$j] . "'")
       unless defined($opcode = $opcode{$arg->{changes}[$j++]});

      my $chg = $arg->{changes}[$j++];
      if (ref($chg)) {
	my $i = 0;
	while ($i < @$chg) {
          push @ops, {
	    operation => $opcode,
	    modification => {
	      type => $chg->[$i],
	      vals => ref($chg->[$i+1]) ? $chg->[$i+1] : [$chg->[$i+1]]
	    }
	  };

lib/Net/LDAP/ASN.pm  view on Meta::CPAN

	matchedDN       LDAPDN,
	errorMessage    LDAPString,
	referral        [3] Referral OPTIONAL }

    Referral ::= SEQUENCE OF URI

    URI ::= LDAPString -- limited to characters permitted in URIs

    Controls ::= SEQUENCE OF Control

    -- Names changed here for backwards compat with previous
    -- Net::LDAP    --GMB
    Control ::= SEQUENCE {
	type            LDAPOID,                       -- controlType
	critical        BOOLEAN OPTIONAL, -- DEFAULT FALSE,    -- criticality
	value           OCTET STRING OPTIONAL }        -- controlValue

    BindRequest ::= [APPLICATION 0] SEQUENCE {
	version         INTEGER, -- (1 .. 127),
	name            LDAPDN,
	authentication  AuthenticationChoice }

lib/Net/LDAP/Control.pm  view on Meta::CPAN


use Net::LDAP::Constant qw(
  LDAP_CONTROL_SORTREQUEST
  LDAP_CONTROL_SORTRESULT
  LDAP_CONTROL_VLVREQUEST
  LDAP_CONTROL_VLVRESPONSE
  LDAP_CONTROL_PAGED
  LDAP_CONTROL_PROXYAUTHORIZATION
  LDAP_CONTROL_MANAGEDSAIT
  LDAP_CONTROL_PERSISTENTSEARCH
  LDAP_CONTROL_ENTRYCHANGE
  LDAP_CONTROL_MATCHEDVALUES
  LDAP_CONTROL_PASSWORDPOLICY
  LDAP_CONTROL_PREREAD
  LDAP_CONTROL_POSTREAD
  LDAP_CONTROL_SYNC
  LDAP_CONTROL_SYNC_STATE
  LDAP_CONTROL_SYNC_DONE
  LDAP_CONTROL_ASSERTION
  LDAP_CONTROL_RELAX
  LDAP_CONTROL_DONTUSECOPY

lib/Net/LDAP/Control/EntryChange.pm  view on Meta::CPAN

# Copyright (c) 2004 Peter Marschall <peter@adpm.de>. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.

package Net::LDAP::Control::EntryChange;

use Net::LDAP::Control;

our @ISA = qw(Net::LDAP::Control);
our $VERSION = '0.02';

use Net::LDAP::ASN qw(EntryChangeNotification);
use strict;

sub init {
  my($self) = @_;

  delete $self->{asn};

  unless (exists $self->{value}) {
    $self->{asn} = {
      changeTypes  => $self->{changeType} || '0',
      previousDN   => $self->{previousDN} || '',
      changeNumber => $self->{changeNumber} || '0',
    };
  }

  $self;
}

sub changeType {
  my $self = shift;
  $self->{asn} ||= $EntryChangeNotification->decode($self->{value});
  if (@_) {
    delete $self->{value};
    return $self->{asn}{changeType} = shift || 0;
  }
  $self->{asn}{changeType};
}

sub previousDN {
  my $self = shift;
  $self->{asn} ||= $EntryChangeNotification->decode($self->{value});
  if (@_) {
    delete $self->{value};
    return $self->{asn}{previousDN} = shift || '';
  }
  $self->{asn}{previousDN};
}

sub changeNumber {
  my $self = shift;
  $self->{asn} ||= $EntryChangeNotification->decode($self->{value});
  if (@_) {
    delete $self->{value};
    return $self->{asn}{changeNumber} = shift || 0;
  }
  $self->{asn}{changeNumber};
}

sub value {
  my $self = shift;

  exists $self->{value}
    ? $self->{value}
    : $self->{value} = $EntryChangeNotification->encode($self->{asn});
}

1;

__END__

=head1 NAME

Net::LDAP::Control::EntryChange - LDAPv3 Entry Change Notification control object

=head1 SYNOPSIS

 use Net::LDAP;
 use Net::LDAP::Control::PersistentSearch;
 use Net::LDAP::Constant qw(LDAP_CONTROL_ENTRYCHANGE);

 $ldap = Net::LDAP->new( "ldap.mydomain.eg" );

 $persist = Net::LDAP::Control::PersistentSearch->new( changeTypes => 15,
                                                       changesOnly => 1,
                                                       returnECs => 1 );

 $srch = $ldap->search( base     => "cn=People,dc=mydomain,dc=eg",
                        filter   => "(objectClass=person)",
                        callback => \&process_entry, # call for each entry
                        control  => [ $persist ] );

 die "error: ",$srch->code(),": ",$srch->error()  if ($srch->code());

 sub process_entry {
   my $message = shift;
   my $entry = shift;
   my ($control) = $message->control(LDAP_CONTROL_ENTRYCHANGE);

   print $control->changeType()."\t".$entry->dn()."\n";
 }


=head1 DESCRIPTION

C<Net::LDAP::Control::EntryChange> provides an interface for the creation
and manipulation of objects that represent the C<EntryChangeNotification>
control as described by draft-smith-psearch-ldap-03.txt.

=head1 CONSTRUCTOR ARGUMENTS

In addition to the constructor arguments described in
L<Net::LDAP::Control> the following are provided.

=over 4

=item changeType

An integer value telling the type of LDAP operation that the entry
has undergone.
It is one of the following values (which represent the LDAP
operations indicated next to them):

=over 4

=item 1 = add

=item 2 = delete

=item 4 = modify

=item 8 = modDN

=back

=item previousDN

When changeType is 8 (for modDN) this parameter tells the entry's DN
before the modDN operation.
In all other cases this value is not defined.

=item changeNumber

This is the change number according to <draft-good-ldap-changelog-03.txt>
assigned by a server for the change.  If a server supports an LDAP
Change Log it should include this field.

=back

Usually you do not need to create a C<Net::LDAP::Control::EntryChange>
control yourself because it is provided by the server in response to
an option with the C<Net::LDAP::Control::PersistentSearch> control.

=head1 METHODS

As with L<Net::LDAP::Control> each constructor argument
described above is also available as a method on the object which will
return the current value for the attribute if called without an argument,
and set a new value for the attribute if called with an argument.

lib/Net/LDAP/Control/ManageDsaIT.pm  view on Meta::CPAN

=head1 SYNOPSIS

 use Net::LDAP;
 use Net::LDAP::Control::ManageDsaIT;

 $ldap = Net::LDAP->new( "ldap.mydomain.eg" );

 $manage = Net::LDAP::Control::ManageDsaIT->new( critical => 1 );

 $msg = $ldap->modify( 'dc=sub,dc=mydomain,dc=eg",
                       changes => [
                         delete => { ref => 'ldap://ldap2/dc=sub,dc=mydom,dc=eg' },
                         add => { ref => 'ldap://ldap3/dc=sub,dc=mydom,dc=eg' } ],
                       control  => [ $manage ] );

 die "error: ",$msg->code(),": ",$msg->error()  if ($msg->code());


=head1 DESCRIPTION

C<Net::LDAP::Control::ManageDsaIT> provides an interface for the creation

lib/Net/LDAP/Control/PasswordPolicy.pm  view on Meta::CPAN

If defined, this contains a more detailed error code for the account.
See L<Net::LDAP::Constant> for definitions of each.
Values can include:

=over 4

=item LDAP_PP_PASSWORD_EXPIRED

=item LDAP_PP_ACCOUNT_LOCKED

=item LDAP_PP_CHANGE_AFTER_RESET

=item LDAP_PP_PASSWORD_MOD_NOT_ALLOWED

=item LDAP_PP_MUST_SUPPLY_OLD_PASSWORD

=item LDAP_PP_INSUFFICIENT_PASSWORD_QUALITY

=item LDAP_PP_PASSWORD_TOO_SHORT

=item LDAP_PP_PASSWORD_TOO_YOUNG

lib/Net/LDAP/Control/PersistentSearch.pm  view on Meta::CPAN

use Net::LDAP::ASN qw(PersistentSearch);
use strict;

sub init {
  my($self) = @_;

  delete $self->{asn};

  unless (exists $self->{value}) {
    $self->{asn} = {
      changeTypes => $self->{changeTypes} || '15',
      changesOnly => $self->{changesOnly} || '0',
      returnECs   => $self->{returnECs} || '0',
    };
  }

  $self;
}

sub changeTypes {
  my $self = shift;
  $self->{asn} ||= $PersistentSearch->decode($self->{value});
  if (@_) {
    delete $self->{value};
    return $self->{asn}{changeTypes} = shift || 0;
  }
  $self->{asn}{changeTypes};
}

sub changesOnly {
  my $self = shift;
  $self->{asn} ||= $PersistentSearch->decode($self->{value});
  if (@_) {
    delete $self->{value};
    return $self->{asn}{changesOnly} = shift || 0;
  }
  $self->{asn}{changesOnly};
}

sub returnECs {
  my $self = shift;
  $self->{asn} ||= $PersistentSearch->decode($self->{value});
  if (@_) {
    delete $self->{value};
    return $self->{asn}{returnECs} = shift || 0;
  }
  $self->{asn}{returnECs};

lib/Net/LDAP/Control/PostRead.pm  view on Meta::CPAN


 my $mesg = $ldap->modify( "cn=Barbara Jensen, o=University of Michigan, c=US",
                           replace => { givenName => "Babs" },
			   control => $postread );

 if ($mesg->code eq LDAP_SUCCESS) {
   my ($afterwards) = $mesg->control( LDAP_CONTROL_PREREAD );
   my $entry = $afterwards ? $afterwards->entry() : undef;

   if ($entry) {
     print "givenName changed to '" .
           join("', '", $entry->get_value(givenName") .
           "' to 'Babs'\n");
   }
 }


=head1 DESCRIPTION

C<Net::LDAP::Control::PostRead> provides an interface for the creation and
manipulation of objects that represent the C<Post-Read Controls> as described

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 5.045 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-cec75d87357c )