From b125a29ac13dbe1f9377d5144399a281f25ea88e Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 9 Feb 2007 06:15:56 +0000 Subject: [PATCH] Added base detection button git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5710 594d385d-05f5-0310-b6e9-bd551577e9d8 --- setup/class_setupStep4.inc | 39 +++++++++++++++++++++++++++++--------- setup/setup_step4.tpl | 30 ++++++++++++++--------------- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/setup/class_setupStep4.inc b/setup/class_setupStep4.inc index c923d7b12..2f916100b 100644 --- a/setup/class_setupStep4.inc +++ b/setup/class_setupStep4.inc @@ -38,7 +38,8 @@ class setup_step_4 extends setup_step var $crypt_methods = array(); var $mail_methods = array(); - var $connect_id =FALSE; + var $connect_id = FALSE; + var $bind_id = FALSE; var $attributes = array("connection","location","admin","password","base","peopleou","peopledn","groupou", "uidbase","encryption","mail","errors"); @@ -63,7 +64,6 @@ class setup_step_4 extends setup_step $smarty->assign("connection_established",$this->is_connection_established()); - $smarty->assign("peopledns",array("uid","cn")); $smarty->assign("crypt_methods",$this->crypt_methods); $smarty->assign("mail_methods",$this->mail_methods); @@ -99,15 +99,31 @@ class setup_step_4 extends setup_step /* Check if specified server is reachable */ function is_connection_established() { - if(!$this->connect_id= @ldap_connect(validate($this->connection))){ - echo "false"; - return FALSE; - }else{ - echo "true"; - return TRUE; - } + + @ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); + $cid = @ldap_connect($this->connection); + + $ds = @ldap_bind($cid, $this->admin, $this->password); + @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); } + + function try_to_get_base_automatically() + { + + @ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); + $cid = @ldap_connect($this->connection); + + $ds = @ldap_bind($cid); + @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); + + $sr= ldap_search ($ds, NULL, "objectClass=*", array("namingContexts")); + $attr= ldap_get_entries($cid,$sr); + echo ldap_error($cid); + print_a($attr); + } + + function save_object() { foreach($this->attributes as $attr){ @@ -115,6 +131,11 @@ class setup_step_4 extends setup_step $this->$attr = $_POST[$attr]; } } + + /* Get base automatically */ + if(isset($_POST['get_base'])){ + $this->try_to_get_base_automatically(); + } } } diff --git a/setup/setup_step4.tpl b/setup/setup_step4.tpl index 3faa404c6..2ad3175cb 100644 --- a/setup/setup_step4.tpl +++ b/setup/setup_step4.tpl @@ -1,31 +1,28 @@

{t}ldap connection{/t}

-
{t}Connection url{/t}
+ {t}Location description{/t}
- +
- {if !$connection_established} - {t}Connection failed{/t} - {/if} - -
-
- -{if $connection_established} -
- {t}Location description{/t} +
{t}Connection url{/t}
- +
+ {if !$connection_established} + {t}Connection failed{/t} + {/if} + +
+
@@ -52,7 +49,6 @@ asd -
{t}Base{/t} @@ -61,10 +57,14 @@
- asd +
+ +{if $connection_established} + +
{t}People storage ou{/t} -- 2.30.2