Net::LDAP::Class::MethodMaker - create methods for Net::LDAP::Class classes


 package MyUser;
 use base qw( Net::LDAP::Class::User );
 use Net::LDAP::Class::MethodMaker (
    'scalar --get_set_init' => [qw( foo )],
    'related_objects'       => [qw( bars )],
    base_dn             => 'dc=local',
    attributes          => [qw( foo )],
    unique_attributes   => [qw( foo )],
 # must define a fetch_bars method
 sub fetch_bars {
    my $user = shift;
    # do something to get bar objects.

 # elsewhere
 my $user = MyUser->new( foo => '1234' )->read or die;
 $user->foo;        # == $user->ldap_entry->get_value('foo');
 $user->foo(5678);  # == $user->ldap_entry->replace( foo => 5678 );
 $user->foo;        # returns '5678'
 my $bars       = $user->bars;  # == $user->fetch_bars;
 push(@$bars, 'new bar');
 my $newbars    = $user->bars;  # != $user->fetch_bars;
 $newbars       = $user->bars;  # == $user->fetch_bars;


Net::LDAP::Class::MethodMaker is a subclass of Rose::Object::MakeMethods::Generic. It extends the base class with two new method types: related_objects and ldap_entry.


The related_objects method type creates three methods for each name when using the 'get_set' (default) interface: name, fetch_name, and clear_name.

The fetch_ method must be defined by your class. It should return values from the LDAP server.

The name method is a get/set method. If nothing is set, it calls through to fetch_. Otherwise, if you have set something, it returns what you have set.

The clear_ method will delete any set value from the object and return it.


The ldap_entry method type supports the 'get_set' interface only.

This method type negotiates the getting and setting of values in the delegate ldap_entry() object.


Similar to the 'scalar --get-set-init' method type but may be called as a class method, in which case it will call through to the class metadata() object.


Peter Karman, <karman at>


Please report any bugs or feature requests to bug-net-ldap-class at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Net::LDAP::Class

You can also look for information at:


The Minnesota Supercomputing Institute sponsored the development of this software.


Copyright 2008 by the Regents of the University of Minnesota. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Net::LDAP::Class, Rose::Object::MakeMethods::Generic