The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::LDAP::Class::User::AD - Active Directory User class

SYNOPSIS

# subclass this class for your local LDAP package MyLDAPUser; use base qw( Net::LDAP::Class::User::AD );

 __PACKAGE__->metadata->setup(
    base_dn             => 'dc=mycompany,dc=com',
    attributes          => __PACKAGE__->AD_attributes,
    unique_attributes   => __PACKAGE__->AD_unique_attributes,
 );
 
 1;
 
 # then use your class
 my $ldap = get_and_bind_LDAP_object(); # you write this
 
 use MyLDAPUser;
 my $user = MyLDAPUser->new( ldap => $ldap, sAMAccountName  => 'foobar' );
 $user->read_or_create;
 for my $group ($user->group, @{ $user->groups }) {
     printf("user %s in group %s\n", $user, $group);
 }

DESCRIPTION

Net::LDAP::Class::User::AD isa Net::LDAP::Class::User implementing the Active Directory LDAP schema.

CLASS METHODS

AD_attributes

Returns array ref of a subset of the default Active Directory attributes. Only a subset is used since the default schema contains literally 100s of attributes. The subset was chosen based on its similarity to the POSIX schema.

AD_unique_attributes

Returns array ref of unique Active Directory attributes.

OBJECT METHODS

All the init_* methods can be specified to the new() constructor without the init_ prefix.

fetch_group

Required MethodMaker method for retrieving primary group from LDAP.

Returns an object of type group_class().

fetch_groups

Required MethodMaker method for retrieving secondary groups from LDAP.

Returns array or array ref (based on context) of objects of type group_class().

gid

Alias for primaryGroupID() attribute.

init_default_home_dir

Returns \home.

init_default_email_suffix

Returns an empty string.

password([plain_password])

Convenience wrapper around unicodePwd() attribute method.

This method will verify plain_password is in the correct encoding that AD expects and set it in the ldap_entry().

If no argument is supplied, returns the string set in ldap_entry() (if any).

action_for_create([ sAMAccountName => username ])

Returns hash ref suitable for creating a Net::LDAP::Batch::Action::Add.

May be called as a class method with explicit uid and uidNumber key/value pairs.

setup_for_write

Utility method for generating default values for various attributes. Called by both action_for_create() and action_for_update().

Returns array of values in this order:

 $groupname, $gid, $givenName, $sn, $cn, $email

action_for_update

Returns array ref suitable for creating a Net::LDAP::Batch::Action::Update.

action_for_delete

Returns action suitable for creating a Net::LDAP::Batch::Action::Delete.

AUTHOR

Peter Karman, <karman at cpan.org>

BUGS

Please report any bugs or feature requests to bug-net-ldap-class at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-LDAP-Class. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

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

    perldoc Net::LDAP::Class

You can also look for information at:

ACKNOWLEDGEMENTS

The Minnesota Supercomputing Institute http://www.msi.umn.edu/ sponsored the development of this software.

COPYRIGHT

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.

SEE ALSO

Net::LDAP