Help LDAP connectivity

Discussion in 'Perl Misc' started by cwoollard@gmail.com, May 12, 2005.

  1. Guest

    Hello, I hope somebody can help me,

    I have this program that is listed below that searches an ldap server
    for parameters passed on the command line.

    It does work but it doesn't skip binary data that is also returned (in
    this case jpeg images). I thought that adding the below line would do
    the trick, but it doesn't seem to. Maybe I am doing something wrong.

    next if ( $entry =~ /;binary$/ );

    Can anybody help

    Thanks
    chris


    use Net::LDAP;

    $server = $ARGV[0];
    $port = getservbyname("ldap","tcp") || "389";
    $basedn = "ou=staff,dc=somewhere,dc=co,dc=uk";
    $scope = "sub";

    $c = new Net::LDAP($server, port=>$port) or
    die "Unable to connect to $server: $@\n";
    $c->bind( ) or die "Unable to bind: $@\n"; # anonymous bind

    $searchobj = $c->search(base => $basedn, scope => $scope,
    filter => $ARGV[1]);
    die "Bad search, errorcode #".$searchobj->code() if $searchobj->code(
    );

    @entries = $searchobj->entries;

    foreach $entry (@entries) {
    next if ( $entry =~ /;binary$/ );
    $entry->dump;
    }
     
    , May 12, 2005
    #1
    1. Advertising

  2. J. Gleixner Guest

    wrote:
    > Hello, I hope somebody can help me,
    >
    > I have this program that is listed below that searches an ldap server
    > for parameters passed on the command line.
    >
    > It does work but it doesn't skip binary data that is also returned (in
    > this case jpeg images). I thought that adding the below line would do
    > the trick, but it doesn't seem to. Maybe I am doing something wrong.
    >
    > next if ( $entry =~ /;binary$/ );
    >
    > Can anybody help


    Take a look at the value of $entry. It seems that it's not the value
    you think it is.

    Hint..

    entries ( )

    Return an array of Net::LDAP::Entry objects that were returned from
    the server.
     
    J. Gleixner, May 12, 2005
    #2
    1. Advertising

  3. Chris Guest

    Ok, you are right.

    If i do

    print("$entry\n");

    i get

    Net::LDAP::Entry=HASH(0x1c21d5c)

    Which is very different from what I expected.

    I have tried printing some of the other variables too.

    print("@entries\n");

    which returns
    Net::LDAP::Entry=HASH(0x1c218b4)

    I think I am not entirely understanding what is going on.

    I think i'll go read up on Net::LDAP::Entry

    thanks
    chris
     
    Chris, May 13, 2005
    #3
  4. Chris Guest

    Hmmmm, maybe I should find another way of doing this.

    CPAN Says:



    dump ( [ FILEHANDLE ] )

    Dump the entry to the given filehandle.

    This method is intended for debugging purposes and does not treat
    binary attributes specially.
     
    Chris, May 13, 2005
    #4
  5. "Chris" <> wrote in news:1115974970.076651.30410
    @z14g2000cwz.googlegroups.com:

    > Ok, you are right.


    Who is right? Please provide some context when you post replies.

    > If i do
    >
    > print("$entry\n");
    >
    > i get
    >
    > Net::LDAP::Entry=HASH(0x1c21d5c)
    >
    > Which is very different from what I expected.


    If $entry refers to an object of type Net::LDAP::Entry, then you should
    be able to use the interface provided by that object to access the
    fields.

    > I think i'll go read up on Net::LDAP::Entry


    Good idea. You should have done it sooner:

    The synopsis in the manual page shows you how to access the attributes of an
    Net::LDAP::Entry object:

    http://search.cpan.org/~gbarr/perl-ldap-0.33/lib/Net/LDAP/Entry.pod

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, May 13, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    555
    Raymond DeCampo
    Feb 21, 2006
  2. rcmn
    Replies:
    1
    Views:
    375
    =?ISO-8859-1?Q?Michael_Str=F6der?=
    Nov 6, 2006
  3. Jason Wold

    using LDAP Controls in ruby-ldap

    Jason Wold, Nov 4, 2004, in forum: Ruby
    Replies:
    5
    Views:
    281
  4. Ian Macdonald
    Replies:
    0
    Views:
    239
    Ian Macdonald
    Mar 15, 2005
  5. James Hughes
    Replies:
    4
    Views:
    351
    James Hughes
    Dec 13, 2005
Loading...

Share This Page