Skip to content

Instantly share code, notes, and snippets.

@blaxter
Created March 23, 2015 16:47
Show Gist options
  • Select an option

  • Save blaxter/60ef4836f341df0cd183 to your computer and use it in GitHub Desktop.

Select an option

Save blaxter/60ef4836f341df0cd183 to your computer and use it in GitHub Desktop.

Revisions

  1. blaxter created this gist Mar 23, 2015.
    22 changes: 22 additions & 0 deletions ldap filter pretty print
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #! perl -slw
    use strict;

    ( my $input = do{ local $/; <DATA> } ) =~ tr[\n][]d;

    my $tab = 0;
    $input =~ s[([()])]{
    $tab-- if $1 eq ')';
    my $modified = "\n" . ( " " x $tab ) . $1;
    $tab++ if $1 eq '(';
    $modified;
    }ge;
    $input =~ s[\n\s+\)][)]g;

    print $input;

    __DATA__
    (& (mailnickname=*) (| (&(objectCategory=person)(objectClass=
    user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(obje
    ctClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))(&(objectCategory=person)
    (objectClass=contact))(objectCategory=group)(objectCategory=publicFolder)(obj
    ectCategory=msExchDynamicDistributionList) ))