CodeIgniter Forums
Shouldn't a custom library be logged as when its loaded ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Shouldn't a custom library be logged as when its loaded ? (/showthread.php?tid=3836)



Shouldn't a custom library be logged as when its loaded ? - El Forum - 10-24-2007

[eluser]scottelundgren[/eluser]
I've written a custom library and saved it as application/libraries/LDAP.php. The library has a custom config file and it is in application/config/LDAP.php. If I have:

applicaation/config/config.php:

$config['log_threshold'] = 4;

applicaation/config/autoload.php:

$autoload['libraries'] = array('LDAP', 'database', 'session', 'validation', 'email');

when I look at my log file I have this snippet:

DEBUG - 2007-10-24 14:48:53 --> Loader Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Config file loaded: config/LDAP.php
DEBUG - 2007-10-24 14:48:53 --> Helpers loaded: form, url
DEBUG - 2007-10-24 14:48:53 --> Database Driver Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Session Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Encrypt Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Validation Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Email Class Initialized
DEBUG - 2007-10-24 14:48:53 --> Controller Class Initialized

and I'm thinking shouldn't I be able to see my LDAP class loaded in my logs? I'm having some weird behaviour with my library so I'm staring my investigation wondering if the library was even loaded.


Shouldn't a custom library be logged as when its loaded ? - El Forum - 10-24-2007

[eluser]zdknudsen[/eluser]
You have to do all logging in your own libraries on your own.

Just put a log_message('debug', "LDAP Class Initialized"); in your library constructor (and anywhere else you might want to log stuff).


Shouldn't a custom library be logged as when its loaded ? - El Forum - 10-24-2007

[eluser]scottelundgren[/eluser]
Right and I'm doing that and absolutely not of the messages are being written to the log:

if ($entry["count"] > 0 ) {
$dn = $entry[0]["distinguishedname"][0];
log_message('debug', "Found dn: ".$dn." for : ".$username);
if (ldap_bind($connection, $dn, $password)) {
return true;
} else {
$this->error = "Could not authenticate ".$username.". Did you mistype your password ?";
log_message('debug', "could not authenticate ".$username);
return false;
}


Shouldn't a custom library be logged as when its loaded ? - El Forum - 10-24-2007

[eluser]zdknudsen[/eluser]
Well. If you have set the correct logging level in your config file then your i would suspect that your library is not being loaded. Smile


Shouldn't a custom library be logged as when its loaded ? - El Forum - 10-26-2007

[eluser]scottelundgren[/eluser]
Got it, I just had to realize that I had to write my own initialization function.

function LDAP(){
log_message('debug', "LDAP Class Initialized");
}


Shouldn't a custom library be logged as when its loaded ? - El Forum - 11-26-2007

[eluser]mypcbox[/eluser]
Hi,

I am looking for an LDAP Authentication Library for CI. How good is this holding up. I is this load to the wiki?

Thanks,

jrod


Shouldn't a custom library be logged as when its loaded ? - El Forum - 11-27-2007

[eluser]scottelundgren[/eluser]
It works fine for our purposes but I haven't posted to the wiki because I didn't write it as a general use library. Our LDAP environment does not allow anonymous searches so the authentication function has a proxy user, does the search for the authenticating user, returns their full bind dn, then attempts to bind as that user with the password supplied by the user, returning false or true if authentication was successful. There are no attribute search functions or abilities you would want for displaying directory data.