LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-11-2015, 01:26 PM   #1
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Perl NET::LDAP Help


Hey All,


I am working on a perl script to do some LDAP stuff and am running into an issue with my attrs LDAP value.

Here is my current subroutine that is giving me issues:

Code:
sub get_name_by_uid {
        my ($ldap, $userid, $base) = @_;
        my @Attrs = ();
        my $mesg = $ldap->search (
                base  => $base,
                attrs => [givenName, sn],
                filter => "(uid=$userid)" );
        if ($mesg->code == 0) {
                my $entry = $mesg->entry(0);

                if ($entry) {
                        return $entry;
                }
                else {
                        return undef;
                }
        }
        else {
                return undef;
        }
}

sub ldap_bind {
        my ($host, $dn, $password) = @_;

        my $ldap = Net::LDAP->new($host);
        my $mesg = $ldap->bind ($dn, password => $password);
        return $ldap if ($mesg->code == 0);
        return undef;
}

The error that I am getting is related to barewords in my attrs line on the get_name_by_uid subroutine:

Bareword "givenName" not allowed while "strict subs" in use at ./test.pl line 60, <DATA> line 522.
Bareword "sn" not allowed while "strict subs" in use at ./test.pl line 60, <DATA> line 522.


I can't seem to find a solution to this and am not a perl expert by any means.

I am trying to setup my subroutine to do an LDAP search with the $userid which is provided as an option to the script and return the givenName and sn LDAP attributes.


Thanks for any help you can provide!
 
Old 05-11-2015, 01:31 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Original Poster
Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Also, I know I can get around this by not using:

Code:
use strict;
But I want to know why this is happening and what I should be doing instead of using the barewords.
 
Old 05-12-2015, 07:19 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,676
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
I cordially suggest that you take this question to http://www.perlmonks.org, a venerable specialty-site for Perl programming where you will get your required answers in minutes.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SAMBA and LDAP - net getlocalsid shows error NT_STATUS_UNSUCCESSFUL jax8 Linux - Server 3 06-17-2013 02:35 PM
Perl net::ldap and Active Directory YankeePride13 Programming 1 01-02-2013 08:42 AM
Perl + LDAP zokken Programming 1 02-24-2012 12:38 PM
perl Net::LDAP err handling kzcom Programming 1 11-13-2010 02:32 AM
perl and net::ldap how to return dn from a search jonlake Programming 2 02-24-2006 12:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration