Re: [PHP] scope of classes in PHP

2006-02-13 Thread Jochem Maas

Stuart Bailey wrote:

Hi
I'm developing an app to administer LDAP (phpLdapAdmin is too complex for the 
customer).
I have created an LDAP class, in a file class_ldap.php. It include methods for 
connecting to the server, binding a DN (effectively login), and adding posix 
groups.


I have an index.php with include_once 'class_ldap.php', which allows me to 
login using the HTTP authentication mechanism.


The connect method stores the resulting connection resource in a global 
variable (included in a config.php file).
When I then go to add the posix group (from add_group.php, that also includes 
class_ldap.php), I find that the global connection variable is not valid.


My question is, do I need to connect and authenticate with the LDAP server 
every time I want to perform an action, or is there a way to establish a 


you need to establish a connection at the start of every request php handles,
typically you perform one  [major] 'action' per request so the short answer is:

'yes'.

the connection to the LDAP server is a 'resource' type variable - php 
'resources'
are only valid for the duration of the script.


connection for the user's session, that is cleared when the user logs out.

Many thanks,

Stuart.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] scope of classes in PHP

2006-02-11 Thread Stuart Bailey
Hi
I'm developing an app to administer LDAP (phpLdapAdmin is too complex for the 
customer).
I have created an LDAP class, in a file class_ldap.php. It include methods for 
connecting to the server, binding a DN (effectively login), and adding posix 
groups.

I have an index.php with include_once 'class_ldap.php', which allows me to 
login using the HTTP authentication mechanism.

The connect method stores the resulting connection resource in a global 
variable (included in a config.php file).
When I then go to add the posix group (from add_group.php, that also includes 
class_ldap.php), I find that the global connection variable is not valid.

My question is, do I need to connect and authenticate with the LDAP server 
every time I want to perform an action, or is there a way to establish a 
connection for the user's session, that is cleared when the user logs out.

Many thanks,

Stuart.
-- 
---
Stuart Bailey BSc (hons) CEng CITP MBCS
 LinuSoft (Proprietor)
   Linux Specialist
(01953) 601294
(07778) 383739
   http://www.linusoft.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php