Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Strange unpredictable problem
Hello everybody,

I encounter a little problem with a script using the Net-LDAP module. I
post here because I believe Net-LDAP is the root of this annoyance,
although I could be wrong of course. I've probably made a mistake so
your help may be very useful ;).
Here's more details :

- script's goal : connection to a list of AD's servers to extract
the 'lastLogon' attribute of all users
- problem : script is sometime hanging so I must kill it, frequency
and server are unpredictables.
- context : the following script is running under Windows with
ActivePerl 5.8.8.822, using Net-LDAP 0.34 provided by ActivePerl itself.
This is mandatory, no possibility to test or use under a Linux distribution.
- others usefuls informations : problem occurs under Windows 2000
SP4 and Server 2003. However, I noticed problem appears a lot more under
Windows 2000 than under Server 2003

What I've tried and noticed :
- tried Net-LDAP 0.35 : no change
- perl's CPU usage when problem occurs : 0%. It seems to wait for
something...
- 'netstat' command always shows connection to AD's server is
established when it's hanging.
- 'netstat' has allowed me to see it's not a particular server
which is causing this trouble.


Here's my source sample :

eval {

my ($page,$flag,$ldap);

$page = Net::LDAP::Control::Paged->new( size => 1000 );
$flag = 1;

# 1- connection
$ldap = Net::LDAP->new( $serveur,
scheme => 'ldap',
timeout => 5,
onerror => 'die',
version => 3,
port => 389,
debug => 0 );

if ( ! defined($ldap) ) { die("connection to server failed\n"); }

$ldap->bind( user@adouest.edf.fr,
password => XXXX
);


# 2- treatment
while( $flag ) {

my ($request,$cookie,$resp);

$request = $ldap->search( base => 'DC=ADOUEST,DC=EDF,DC=FR'
scope => 'sub',
deref => 'never',
sizelimit => 0,
timelimit => 300,
typesonly => 0,
filter => '(&
 (objectclass=top)(objectclass=person)(ob
jectclass=organizationalPerson)(obje
ctclass=user)(!
(objectclass=computer) ))',
attrs => [ 'lastLogon' ],
control  => [ $page ]
);

foreach my $entry ( \($request->entries()) ) {

my $dn;

# DN
$dn = $$entry->dn();

if ( defined($user{$dn}) && $$entry->exists('lastLogon') ) {

my $date =
&ConvertTime($$entry->get_value('lastLogon', alloptions => 0, asref =>
0));
if ( defined($user{$dn}{'lastLogon'}) ) {

if ( $user{$dn}{'lastLogon'} < $date ) {
$user{$dn}{'lastLogon'} = $date; }

} else {

$user{$dn}{'lastLogon'} = $date;

}

}

}

($resp) = $request->control(LDAP_CONTROL_PAGED);
$cookie = $resp->cookie() or $flag = 0;
$page->cookie($cookie);

}

# 3- end
die('success');

};
if ( $@ ) {

print 'status : ' . $@ . "\n";

# deconnection
if ( defined($ldap) ) {

eval {

$ldap->unbind();
$ldap->disconnect();

};

}

}

}

Las note : i remarked this on Net::LDAP::Paged doc page :

if ($cookie) {
# We had an abnormal exit, so let the server know we do not want any more
$page->cookie($cookie);
$page->size(0);
$ldap->search( @args );
}

was added just after the loop. I judged this unnecessary because I'm using t
he 'die' method on error. But I may be wrong...

Anyway, any help would be greatly appreciated.

Thanks.

Mickaƫl




Report this thread to moderator Post Follow-up to this message
Old Post
MickB
05-04-08 10:16 AM


Re: Strange unpredictable problem
Hi,

On Sunday, 4. May 2008, MickB wrote:
> Hello everybody,
>
> I encounter a little problem with a script using the Net-LDAP module. I
> post here because I believe Net-LDAP is the root of this annoyance,
> although I could be wrong of course. I've probably made a mistake so
> your help may be very useful ;).
> Here's more details :
>
>     - script's goal : connection to a list of AD's servers to extract
> the 'lastLogon' attribute of all users
>     - problem : script is sometime hanging so I must kill it, frequency
> and server are unpredictables.
>     - context : the following script is running under Windows with
> ActivePerl 5.8.8.822, using Net-LDAP 0.34 provided by ActivePerl itself.
> This is mandatory, no possibility to test or use under a Linux
> distribution. - others usefuls informations : problem occurs under Windows
> 2000 SP4 and Server 2003. However, I noticed problem appears a lot more
> under Windows 2000 than under Server 2003
>
>     What I've tried and noticed :
>        - tried Net-LDAP 0.35 : no change
>        - perl's CPU usage when problem occurs : 0%. It seems to wait for
> something...
>        - 'netstat' command always shows connection to AD's server is
> established when it's hanging.
>        - 'netstat' has allowed me to see it's not a particular server
> which is causing this trouble.
>
> [...]
>
> was added just after the loop. I judged this unnecessary because I'm using
> the 'die' method on error. But I may be wrong...
>
> Anyway, any help would be greatly appreciated.

I did not look at the code, but did you try to check
- using Net::LDAP's debug method/option
- with a network sniffer
to see in more detail what's going on?

Maybe it's the server not responding.

Regards
Peter

--
Peter Marschall
peter@adpm.de

Report this thread to moderator Post Follow-up to this message
Old Post
Peter Marschall
05-05-08 12:44 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

LDAP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:37 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.