I'm grabbing an email address that is in a different OU that what I'm writing to. I am able to grab this email address but I don't know how to add it to my ldap entry. How do I get the address that I'm printing added to my entry?
$entry = $AD_conn->search($adld{root}, $adld{scope}, "(&(|(employ +eeID=$UMF))(mail=*))", 0, @attr); if (!$entry) { my $code = $AD_conn->getErrorCode(); if ($code == 0) { print "No Directory records found to process on this run.\n" } else { print "Run terminated on LDAP Error=" . $AD_conn->getErrorStri +ng() . ".\n"; } #$AD_conn->close(); } else { while($entry) { print "employeeID mail: $entry->{mail}[0],\n"; $entry = $AD_conn->nextEntry(); } # End of while loop } my $ID = $entry->{mail}[0]; # Create the new Directory entry # $entry = new Mozilla::LDAP::Entry; $entry->setDN(("cn=$CN,OU=FunctionalContacts,OU=Functional,OU=Exch +ange,OU=Services,") . $adld{root}); $entry->addValue("objectclass", "top"); $entry->addValue("objectclass", "organizationalPerson"); $entry->addValue("objectclass", "person"); $entry->addValue("objectclass", "contact"); $entry->addValue("description", "POC:$ID"); $fa_values{"mailnickname"} = $username; while (($attr,$value) = each %fa_values) { $entry->addValue($attr, $value); } $AD_conn->add($entry); if ($AD_conn->getErrorCode()) { print "FAILED create_record:$entry->{mailNickname}[0] because '" . + $AD_conn->getErrorString() . "'\n\n"; } else { print "Created mailNickname:$entry->{mailNickname}[0]\n"; } }
I'm getting this error: Can't use string ("") as a HASH ref while "strict refs" in use at ./functionals.pl line 384.

which is: my $ID = $entry->{mail}[0];

What do I need to do to be able to add the mail address that is being retrieved into the description?

output from print:
employeeID mail: jim.doe@xxxx.com,
employeeID mail: john.smith@xxxx.com,
employeeID mail: mark.jones@xxxx.com,
employeeID mail: mark.jones@xxxx.com,
No Directory records found to process on this run.
employeeID mail: john.doe@xxxx.com,


In reply to Adding attribut to AD by mr_evans2u

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.