On 19 Aug 2004, at 14:23, Mark Drummond wrote:

I'm working on a script to import a bunch of sendmail aliases as LDAP groups. Once I have created the initial group, I want to add rfc822MailMembers and uniqueMembers to it. SO I have something like this (largely pilfered from the Examples doc):

while (<ALIASES>) {
        chomp;
        ($groupname,@groupmembers) = split /:/;

        # Create the group entry here
        my $createArray = [
                objectClass => [ "top", "groupOfUniqueNames",
                        "inetMailGroup", "inetLocalMailRecipient",
                        "inetMailGroupManagement", "nsManagedMailList" ],
                cn => "$groupname",
                mail => "[EMAIL PROTECTED]",
                mailHost => "mail.foo.com",
                inetMailGroupStatus => "active"
        ];

        my $newDN = "cn=$groupname,$grpdn";

        print "Creating group: $groupname\n";
        print "dn: $newDN\n";
        LDAPentryCreate($ldap, $newDN, $createArray);

        # Now add the group members
        print "Group $groupname has the following members:\n";
        foreach $groupmember (@groupmembers) {

Previously (other scripts) I had used $entry->add(FOO) to add attributes to an $entry object. But now I don't have an entry object right? LDAPentryCreate does not return an entry object to me? So how do I go about adding my members to this new created group? Do I need to do a search to acquire an $entry object, or is there a better way to do this? Some way to add the members to the createArray prior to calling LDAPentrycreate?

You could use Net::LDAP::Entry directly with

my $entry = Net::LDAP::Entry->new;
$entry->dn($newDN);
$entry->add(
objectClass => [ "top", "groupOfUniqueNames",
"inetMailGroup", "inetLocalMailRecipient",
"inetMailGroupManagement", "nsManagedMailList" ],
cn => "$groupname",
mail => "[EMAIL PROTECTED]",
mailHost => "mail.foo.com",
inetMailGroupStatus => "active"
);


Then after you have added your members do

$ldap->add($entry);

Graham.



Reply via email to