A simpler way than reading the syntax (note though that is the 'correct' way to
do it) is to use code like:

    foreach my $attr ($entry->attributes) {
      print $attr;
      foreach my $val ($entry->get_value($attr)) {
        $val = 'Not ASCII' unless ($val =~ /^[\x00-\x7f]+$/ );
        print "  $val\n";
      }
    }

  --Jim Harle


On Sat, 29 Nov 2003, Chris Ridd wrote:

> On 29/11/03 5:53 pm, Diffenderfer, Randy <[EMAIL PROTECTED]> wrote:
>
> > Folks,
> >
> > This should be simple, but I can't find the answer in the FM's...
> >
> > I do a search, get a set of entries as a result.  Now I want to "dump" them.
> > When printing, how do I simply distinguish a binary attribute?  There are a
> > bunch of these things in the AD schema...
>
> The correct way is to look at the attribute definitions in the schema (ie
> Net::LDAP::Schema) you download from AD, and then look at the syntax defined
> for each attribute.
>
> Your script needs to "know" that certain syntaxes are human-readable and
> that certain syntaxes are not. There's no information in the downloaded
> schema which tells you this, although RFC 2252 section 4.3.2 gives a list of
> which standard syntaxes are human-readable or not. I suspect AD defines a
> whole load of non-standard syntaxes, so you'll need to look through MSDN to
> track down specs of each of these. AD might even change standard syntaxes.
> (It changes standard object classes, so I wouldn't put it past them!)
>
> You should also look at any attribute descriptions. In particular, the
> ";binary" description says that the value is BER-encoded (ie not just
> binary) and that overrides any string representation of the attribute's
> syntax.
>
> There's some existing code which might also help.
>
> Net::LDAP::Entry has a dump method which just prints each attribute value,
> so probably isn't useful.
>
> Net::LDAP::LDIF will however correctly write each attribute value, though
> only based on what bytes are present in each value. It might be a useful
> first cut at a safe 'dump' method.
>
> Cheers,
>
> Chris
>

Reply via email to