Hi,

I'm fairly new to Perl, and the task has fallen upon me to write a reusable sub to authenticate not only a users username and password, but also a given group against NDS.

I have the sub written, and it works great except that it will only compare the given group against the first cn in the groupMemberships returned by the server. Following are code snippets:

$mesg = $ldap->search(base => "o=UMMC", filter => $filter, attrs => ["dn"]); ... $entry = $mesg->shift_entry; $mesg = $ldap->bind($entry->dn, password => "$passWord"); ... #The following is meant to convert the group name passed #in to cn form, because only "group01" would be passed $groupCmp = $entry->dn; $groupCmp =~ s/(cn=)(.*?)(,.*)/$1$group$3/; $mesg = $ldap->compare($entry->dn, attr => "groupMembership",va +lue => "$groupCmp");
Like I said, if I try to match anything other than the first entry in the groupMembership attribute this code returns an LDAP_CONSTRAINT_VIOLATION rather than the expected LDAP_COMPARE_TRUE or LDAP_COMPARE_FALSE.

Can anyone give me any insight into either what I'm doing wrong or a better way to handle this?

Thanks

In reply to Net::LDAP, groupMembership, and compare by Anonymous Monk

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.