[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 # Copyright (c) 2008 Peter Marschall <peter@adpm.de>. All rights reserved. 2 # This program is free software; you can redistribute it and/or 3 # modify it under the same terms as Perl itself. 4 5 package Net::LDAP::Control::PreRead; 6 7 use vars qw(@ISA $VERSION); 8 use Net::LDAP::Control; 9 10 @ISA = qw(Net::LDAP::Control); 11 $VERSION = "0.01"; 12 13 use Net::LDAP::ASN qw(AttributeDescriptionList prSearchResultEntry); 14 use Net::LDAP::Entry; 15 use strict; 16 17 # use some kind of hack here: 18 # - calling the control without args means: response, 19 # - giving an argument: means: request 20 sub init { 21 my($self) = @_; 22 23 delete $self->{asn}; 24 25 unless (exists $self->{value}) { 26 $self->{asn} = $self->{attrs} || []; 27 } 28 29 $self; 30 } 31 32 sub attrs { 33 my $self = shift; 34 35 $self->{asn} ||= $AttributeDescriptionList->decode($self->{value}); 36 if (@_) { 37 delete $self->{value}; 38 return $self->{asn} = [ @_ ]; 39 } 40 41 $self->{asn}; 42 } 43 44 sub entry { 45 my $self = shift; 46 my %opt = @_; 47 my $entry; 48 49 if ($self->{value}) { 50 my $data = $prSearchResultEntry->decode($self->{value}); 51 52 $entry = Net::LDAP::Entry->new; 53 $entry->decode($data, raw => $opt{raw} || $self->{raw}); 54 } 55 56 $entry; 57 } 58 59 sub value { 60 my $self = shift; 61 62 exists $self->{value} 63 ? $self->{value} 64 : $self->{value} = $AttributeDescriptionList->encode($self->{asn}); 65 } 66 67 1; 68 69 70 __END__ 71 72 =head1 NAME 73 74 Net::LDAP::Control::PreRead - LDAPv3 Pre-Read control object 75 76 =head1 SYNOPSIS 77 78 use Net::LDAP; 79 use Net::LDAP::Control::PreRead; 80 use Net::LDAP::Constant qw( LDAP_CONTROL_PREREAD LDAP_SUCCESS ); 81 82 $ldap = Net::LDAP->new( "ldap.mydomain.eg" ); 83 84 $preread = Net::LDAP::Control::Paged->new( attrs => [ qw/givenName/ ] ); 85 86 my $mesg = $ldap->modify( "cn=Barbara Jensen, o=University of Michigan, c=US", 87 replace => { givenName => "Babs" }, 88 control => $preread ); 89 90 if ($mesg->code eq LDAP_SUCCESS) { 91 my ($previous) = $mesg->control( LDAP_CONTROL_PREREAD ); 92 my $entry = $previous ? $previous->entry() : undef; 93 94 if ($entry) { 95 print "givenName changed from '" . 96 join("', '", $entry->get_value(givenName") . 97 "' to 'Babs'\n"); 98 } 99 } 100 101 102 =head1 DESCRIPTION 103 104 C<Net::LDAP::Control::PreRead> provides an interface for the creation and 105 manipulation of objects that represent the C<Pre-Read Control> as described 106 by RFC 4527. 107 108 =head1 CONSTRUCTOR ARGUMENTS 109 110 In addition to the constructor arguments described in 111 L<Net::LDAP::Control> the following are provided. 112 113 =over 4 114 115 =item attrs => [ ATTR, ... ] 116 117 A list of attributes to be returned in the entry returned in the response control. 118 119 If absent, all attributes are returned. 120 121 Operational attributes may be included in the list by explicitely asking for them 122 or by using special C<"+"> feature (provided the server supports this feature). 123 124 =back 125 126 =head1 METHODS 127 128 As with L<Net::LDAP::Control> each constructor argument 129 described above is also avaliable as a method on the object which will 130 return the current value for the attribute if called without an argument, 131 and set a new value for the attribute if called with an argument. 132 133 In addition to these methods, the control also supports the following method: 134 135 =over 4 136 137 =item entry () 138 139 Returns the entry from the response control in the response message 140 to the LDAP request that contained the request control. 141 142 The result is either a Net::LDAP::Entry object or undefined. 143 144 =back 145 146 147 =head1 SEE ALSO 148 149 L<Net::LDAP>, 150 L<Net::LDAP::Control>, 151 http://www.ietf.org/rfc/rfc4527.txt 152 153 =head1 AUTHOR 154 155 Peter Marschall E<lt>peter@adpm.deE<gt> 156 157 Please report any bugs, or post any suggestions, to the perl-ldap mailing list 158 E<lt>perl-ldap@perl.orgE<gt> 159 160 =head1 COPYRIGHT 161 162 Copyright (c) 2008 Peter Marschall. All rights reserved. This program is 163 free software; you can redistribute it and/or modify it under the same 164 terms as Perl itself. 165 166 =cut 167
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |