From: Philip C. <pch...@go...> - 2001-05-10 19:27:09
|
I have been experiencing a relatively strange problem using both OpenLDAP and IBM Secure Way Directory. At this point I only care about OpenLDAP since that is what we have chosen to go with... In a nutshell, I am creating a CGI interface for maintaining email accounts. One of its many functions is listing domains a reseller controls and listing users within a given domain. The first time around I set the max records per page (users or domains) to 25 and this worked... for a little while. I had some problems, without changing code and decided to drop it to 20. Suddenly the problems manifested again and I had to drop the limit of records to 10. That worked for a bit and now I am down to 5 domains/users per page. I setup some logging to see what was happening... Under some circumstances I would get back the initial max records (5, 10, 20, 25) but if I hit the 'Next' button which had worked only moments before my processing would stop prematurely on a record and not continue. It seems odd to me that I could get the initial listing of x once but not again. In a more detailed example, one domain has 100 users within it and for each user there are two LDAP records totaling 201 records (one record for the user and each user then posessing a branch from their user record) for the domain (one for the domain itself). I search the base of the domain with Net::LDAP, tho before I do that I need to do two other searches in the form of: ## in the interest of simplifying this already ugly example I have omitted error ## checking ... which really only checks to make sure the search returned ok ## summarize the total domain aliases $m = $Ldap->search( base => 'dc=example, dc=com, dc=domains, dc=cluster00, dc=valuemail, dc=net', filter => '(&(objectclass=localMailRcpt)(objectclass=distList)(!(objectclass=user))(!(objectclass=autoResponder)))', ## try to conserver mem by limiting amount returned attrs => [qw(mailLocaLaddr)], ## only search directly above the domain entry in user name space scope => 'one' ); $domainAliases = $m->count(); ## hoping this frees resources? $Ldap->abandon($m->mesg_id()); ## summarize the total domain autoresponders $m = $Ldap->search( base => 'dc=example, dc=com, dc=domains, dc=cluster00, dc=valuemail, dc=net', filter => '(&(objectclass=localMailRcpt)(objectclass=distList)(objectclass=autoResponder)(!(objectclass=user)))', ## try to conserver mem by limiting amount returned attrs => [qw(mailLocaLaddr)], ## only search directly above the domain entry in user name space scope => 'one' ); $domainAutoReponders = $m->count(); ## hoping this frees resources? $Ldap->abandon($m->mesg_id()); ## then grab a list of users $m = $Ldap->search( base => 'dc=example, dc=com, dc=domains, dc=cluster00, dc=valuemail, dc=net', filter => '(&(objectclass=localmailrcpt)(authname=*))', ## try to conserver mem by limiting amount returned attrs => [qw(objectclass dn uiCaps authName userQuota listMemeber)], ## only search directly above the domain entry in user name space scope => 'one' ); ## at this point each entry is processed and I log which entry it is processing ## slowly but surely the number of entries capable of being processed is ## shrinking????? ## PROCESSING USER ENTRIES ## ## MIN is what ever the last page's MAX was + MAX + 1 ## ie $oldmax = 5 ## $newmin = $oldmax + MAX + 1 # MAX == 5 ## $newmax = $newmin + MAX + 1 for($i = $newmin; $i <= $newmax; $i++) { last if($i > $m->count()-1); $e = $m->entry($i); ## process entry } ## finally print it all to the user Within this example $domainAliases and $domainAutoReponders only return 1 since that is how many of each are present which actually brings the total number of records up to 204 (domainAliases only have one rec per entry). Would a call back be appropriate to conserve memory here? I would assume that is the problem... But I am not sure at this point... Are the $Ldap->abandon()'s even helping to free memory? Am I looking at this all wrong? Is there another issue which I am not even aware of at work here? It seems odd that this happened on two different ldap servers and that at some points I can list the initial page, but the processing of entries will halt half way through another listing? Please tell me someone has experienced this!?!?!?! Arrrrgh!!! One more thing I think I should metion, this has happened to me using both AIX/Secure Way and OpenLDAP on VA Linux... Running my code on two seperate VA Linux boxes (not on the VA with OpenLDAP). -- Philip Champon Valueweb Developer Ph - 954-334-8156 Em - pch...@va... |