NAME

SPOPS::ClassFactory::LDAP - Create relationships among LDAP objects

SYNOPSIS

In configuration:

my $config = {
   object => {
     class    => 'My::Object',
     isa      => [ 'SPOPS::LDAP' ],
     has_a    => { 'My::OtherObject'   => 'field' },
     links_to => { 'My::AnotherObject' => 'uniquemember',
                   'My::YAObject'      => 'myfield', },
   },
};

DESCRIPTION

This class implements two types of relationships: 'has_a' and 'links_to'.

The 'has_a' relationship exists where one object has the information for one or more objects of another type in its own properties. The DN(s) for the other object(s) are held in one of the object properties.

For instance, one of the objects represented in the standard LDAP schema is a group. This has the object class 'groupOfUniqueNames' and a property 'uniquemember' which may have zero, one or more DNs for member objects.

The 'links_to' relationship exists where one object is related to one or more objects of another type, but the information is held in the property of the other object. So a member of one or more groups would use a 'links_to' relationship to find all the groups to which the member belongs.

As an example of both of these, take the canonical relationship of users to groups. The group object 'has_a' zero or more user objects since it is a 'groupOfUniqueNames' and has the property 'uniquemember'. So we would define it:

group => {
   class    => 'My::Group',
   isa      => [ 'SPOPS::LDAP' ],
   has_a    => { 'My::User' => 'uniquemember' },
},

So a group that had the following DNs in its 'uniquemember' field:

cn=Fred Flintstone,ou=People,dc=hanna-barberra,dc=com
cn=Wilma Flintstone,ou=People,dc=hanna-barberra,dc=com
cn=Dino,ou=People,dc=hanna-barberra,dc=com

would return user objects for Fred, Wilma and Dino.

The user object might be defined:

user => {
   class    => 'My::User',
   isa      => [ 'SPOPS::LDAP' ],
   links_to => { 'My::Group' => 'uniquemember' },
},

And would find all groups that had its DN in the field 'uniquemember' of the group objects.

This is generally more straightforward than the DBI equivalent.

METHODS

Note: Even though the first parameter for all behaviors is $class, they are not class methods. The parameter refers to the class into which the behaviors will be installed.

conf_relate_has_a( $class )

See above for an explanation of how to configure this.

The 'a' part of the 'has_a' term is a bit of a misnomer -- this works whether the property has one or more DNs. It creates a single method named for the alias of the class to which it is linking. So:

group => {
    class => 'My::Group',
    isa   => [ 'SPOPS::LDAP' ],
    has_a => { 'My::User' => 'uniquemember' },
},
user => {
    class => 'My::User',
},

Would create a method 'user' so you could do:

my $user_list = $group->user;
foreach my $user ( @{ $user_list } ) {
    print "DN: ", $user->dn, "\n";
}

conf_relate_links_to( $class )

This creates three methods for every entry.

  • $alias: Returns an arrayref of objects to which this object is linked.

  • $alias_add( \@id_list ): Adds links for this object to every object specified in \@id_list.

  • $alias_remove: Removes links to this object from every object specified in \@id_list.

conf_fetch_by( $class )

Do not use the 'fetch_by' implemented by SPOPS (yet), so stop the processing of this slot here.

BUGS

None known.

TO DO

Implement 'fetch_by'

Implement 'fetch_by' functionality.

SEE ALSO

SPOPS::LDAP

Net::LDAP

SPOPS

COPYRIGHT

Copyright (c) 2001 MSN Marketing Services Nordwest, GmbH. All rights reserved.

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

AUTHORS

Chris Winters <chris@cwinters.com>