Hello

For my work, I need to get a list of users from an Active Directory (Win2003) including a lot of subdomains and write them to an LDIF file. Well, I decided to try it with Perl and ADSI and basically it works fine.

But there is one problem: I need to convert binary attribute values (e.g. objectGUID) to hex, but I don't know how to find out if a value is binary or not.

Here are some fragments of my code, stripped down to the essentials

# $adsPath is a path to a single userobject returned by a # previous search by the global catalog, just GC:// replaced # with LDAP://, e.g. # LDAP://ADS_Server/CN=Panther\, Paul,OU=test,DC=xyz,DC=de my $object = Win32::OLE->GetObject($adsPath); unless ($object) { # ... } foreach my $attr (@$attributeList) { if (ref($object->{$attr}) eq 'ARRAY') { # ... } # if elsif (ref($object->{$attr})) { # ... } # elsif elsif (defined $object->{$attr}) { if ( ???????? ) { # binary -> print as hex-string print "$attr: ", unpack("H*", $value), "\n"; } # if else { # text -> print as text print "$attr: $value\n"; } # else } # elsif } # foreach # .....

Do you know how I can find it out with ADSI?

Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"


In reply to ADSI -> how to recognize binary attribute values by strat

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.