2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-10-27 18:47:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  This  code  is  part  of  LDAP  Account  Manager  ( http :// www . ldap - account - manager . org / ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-18 08:19:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  Copyright  ( C )  2003  -  2018   Roland  Gruber 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  This  program  is  free  software ;  you  can  redistribute  it  and / or  modify 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  it  under  the  terms  of  the  GNU  General  Public  License  as  published  by 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  the  Free  Software  Foundation ;  either  version  2  of  the  License ,  or 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ( at  your  option )  any  later  version . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  This  program  is  distributed  in  the  hope  that  it  will  be  useful , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  but  WITHOUT  ANY  WARRANTY ;  without  even  the  implied  warranty  of 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  MERCHANTABILITY  or  FITNESS  FOR  A  PARTICULAR  PURPOSE .   See  the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  GNU  General  Public  License  for  more  details . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  You  should  have  received  a  copy  of  the  GNU  General  Public  License 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  along  with  this  program ;  if  not ,  write  to  the  Free  Software 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  Foundation ,  Inc . ,  59  Temple  Place ,  Suite  330 ,  Boston ,  MA   02111 - 1307   USA 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-07-10 09:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*/  
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-07-10 09:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/**  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  Creates  main  suffixes  if  they  are  missing .  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  @ author  Roland  Gruber  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  @ package  main  
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								*/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-03-26 17:51:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/** security functions */  
						 
					
						
							
								
									
										
										
										
											2018-12-23 16:21:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								include_once ( __DIR__  .  " /../lib/security.inc " );  
						 
					
						
							
								
									
										
										
										
											2004-07-10 09:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/** access to configuration settings */  
						 
					
						
							
								
									
										
										
										
											2018-12-23 16:21:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								include_once ( __DIR__  .  " /../lib/config.inc " );  
						 
					
						
							
								
									
										
										
										
											2004-07-10 09:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/** LDAP access */  
						 
					
						
							
								
									
										
										
										
											2018-12-23 16:21:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								include_once ( __DIR__  .  " /../lib/ldap.inc " );  
						 
					
						
							
								
									
										
										
										
											2004-07-10 09:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/** status messages */  
						 
					
						
							
								
									
										
										
										
											2018-12-23 16:21:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								include_once ( __DIR__  .  " /../lib/status.inc " );  
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// start session
  
						 
					
						
							
								
									
										
										
										
											2006-03-26 17:51:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								startSecureSession ();  
						 
					
						
							
								
									
										
										
										
											2017-02-11 16:11:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								enforceUserIsLoggedIn ();  
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-12-30 16:08:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( ! checkIfWriteAccessIsAllowed ())  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									die (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								setlanguage ();  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-15 19:16:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( ! empty ( $_POST ))  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									validateSecurityToken (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// check if user already pressed button
  
						 
					
						
							
								
									
										
										
										
											2010-05-07 19:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( isset ( $_POST [ 'add_suff' ])  ||  isset ( $_POST [ 'cancel' ]))  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( isset ( $_POST [ 'add_suff' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 10:33:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$failedDNs  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$newSuffixes  =  $_POST [ 'new_suff' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$newSuffixes  =  str_replace ( " \\ " ,  " " ,  $newSuffixes ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$newSuffixes  =  str_replace ( " ' " ,  " " ,  $newSuffixes ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$newSuffixes  =  explode ( " ; " ,  $newSuffixes ); 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// add entries
 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 10:33:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										foreach  ( $newSuffixes  as  $newSuffix )  { 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// check if entry is already present
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-04 18:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$info  =  @ ldap_read ( $_SESSION [ 'ldap' ] -> server (),  escapeDN ( $newSuffix ),  " objectclass=* " ,  array ( 'dn' ),  0 ,  0 ,  0 ,  LDAP_DEREF_NEVER ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$res  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $info  !==  false )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$res  =  ldap_get_entries ( $_SESSION [ 'ldap' ] -> server (),  $info ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( $res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 10:33:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$suff  =  $newSuffix ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											// generate DN and attributes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$tmp  =  explode ( " , " ,  $suff ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$name  =  explode ( " = " ,  $tmp [ 0 ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											array_shift ( $tmp ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$end  =  implode ( " , " ,  $tmp ); 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( $name [ 0 ]  !=  " ou " )  {   // add root entry
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$attr  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$attr [ $name [ 0 ]]  =  $name [ 1 ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$attr [ 'objectClass' ]  =  'organization' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$dn  =  $suff ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( !@ ldap_add ( $_SESSION [ 'ldap' ] -> server (),  $dn ,  $attr ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-04 18:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													$failedDNs [ $suff ]  =  ldap_error ( $_SESSION [ 'ldap' ] -> server ()); 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											else  {   // add organizational unit
 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												$name  =  $name [ 1 ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$attr  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$attr [ 'objectClass' ]  =  " organizationalunit " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$attr [ 'ou' ]  =  $name ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$dn  =  $suff ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-10-11 15:23:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  ( !@ ldap_add ( $_SESSION [ 'ldap' ] -> server (),  $dn ,  $attr ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													// check if we have to add parent entries
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													if  ( ldap_errno ( $_SESSION [ 'ldap' ] -> server ())  ==  32 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-24 19:06:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$dnParts  =  explode ( " , " ,  $suff ); 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$subsuffs  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														// make list of subsuffixes
 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-24 19:06:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$dnPartsCount  =  sizeof ( $dnParts ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														for  ( $k  =  0 ;  $k  <  $dnPartsCount ;  $k ++ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															$part  =  explode ( " = " ,  $dnParts [ $k ]); 
							 
						 
					
						
							
								
									
										
										
										
											2018-12-29 14:49:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															if  ( $part [ 0 ]  ==  " ou " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																$subsuffs []  =  implode ( " , " ,  array_slice ( $dnParts ,  $k )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															} 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-24 19:06:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																$subsuffs []  =  implode ( " , " ,  array_slice ( $dnParts ,  $k )); 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														// create missing entries
 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-24 19:06:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$subsuffCount  =  sizeof ( $subsuffs ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														for  ( $k  =  $subsuffCount  -  1 ;  $k  >=  0 ;  $k -- )  { 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															// check if subsuffix is present
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-04 18:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															$info  =  @ ldap_read ( $_SESSION [ 'ldap' ] -> server (),  escapeDN ( $subsuffs [ $k ]),  " objectclass=* " ,  array ( 'dn' ),  0 ,  0 ,  0 ,  LDAP_DEREF_NEVER ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															$res  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															if  ( $info  !==  false )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																$res  =  ldap_get_entries ( $_SESSION [ 'ldap' ] -> server (),  $info ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															} 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															if  ( ! $res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																$suffarray  =  explode ( " , " ,  $subsuffs [ $k ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																$headarray  =  explode ( " = " ,  $suffarray [ 0 ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																if  ( $headarray [ 0 ]  ==  " ou " )  {   // add ou entry
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	$attr  =  array (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	$attr [ 'objectClass' ]  =  'organizationalunit' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	$attr [ 'ou' ]  =  $headarray [ 1 ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	$dn  =  $subsuffs [ $k ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	if  ( !@ ldap_add ( $_SESSION [ 'ldap' ] -> server (),  $dn ,  $attr ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-04 18:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																		$failedDNs [ $suff ]  =  ldap_error ( $_SESSION [ 'ldap' ] -> server ()); 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																		break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																else  {   // add root entry
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	$attr  =  array (); 
							 
						 
					
						
							
								
									
										
										
										
											2004-01-07 17:45:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																	$attr [ 'objectClass' ][]  =  'organization' ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																	$attr [ $headarray [ 0 ]]  =  $headarray [ 1 ]; 
							 
						 
					
						
							
								
									
										
										
										
											2004-01-07 17:45:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																	if  ( $headarray [ 0 ]  ==  " dc " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																		$attr [ 'o' ]  =  $headarray [ 1 ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																		$attr [ 'objectClass' ][]  =  'dcObject' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	} 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																	$dn  =  $subsuffs [ $k ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	if  ( !@ ldap_add ( $_SESSION [ 'ldap' ] -> server (),  $dn ,  $attr ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-04 18:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																		$failedDNs [ $suff ]  =  ldap_error ( $_SESSION [ 'ldap' ] -> server ()); 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																		break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													else  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-04 18:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$failedDNs [ $suff ]  =  ldap_error ( $_SESSION [ 'ldap' ] -> server ()); 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 17:48:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2003-10-11 15:23:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-18 08:19:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									include  '../lib/adminHeader.inc' ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-29 11:33:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// print error/success messages
 
							 
						 
					
						
							
								
									
										
										
										
											2010-05-07 19:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( isset ( $_POST [ 'add_suff' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 10:33:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( sizeof ( $failedDNs )  >  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 20:41:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// print error messages
 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-04 18:27:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											foreach  ( $failedDNs  as  $suffix  =>  $error )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												StatusMessage ( " ERROR " ,  _ ( " Failed to create entry! " )  .  " <br> "  .  htmlspecialchars ( $error ),  htmlspecialchars ( $suffix )); 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-29 11:33:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-18 08:19:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											include  '../lib/adminFooter.inc' ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-29 11:33:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 20:41:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// print success message
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											StatusMessage ( " INFO " ,  " " ,  _ ( " All changes were successful. " )); 
							 
						 
					
						
							
								
									
										
										
										
											2010-08-21 09:43:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											include  'main_footer.php' ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-11-03 20:41:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// no suffixes were created
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										StatusMessage ( " INFO " ,  " " ,  _ ( " No changes were made. " )); 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-18 08:19:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										include  '../lib/adminFooter.inc' ; 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-29 11:33:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									exit ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// first show of page
  
						 
					
						
							
								
									
										
										
										
											2017-09-17 10:33:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$newSuffixes  =  $_GET [ 'suffs' ];  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$newSuffixes  =  str_replace ( " \\ " ,  " " ,  $newSuffixes );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$newSuffixes  =  str_replace ( " ' " ,  " " ,  $newSuffixes );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$newSuffixes  =  explode ( " ; " ,  $newSuffixes );  
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-23 16:21:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								include  __DIR__  .  '/../lib/adminHeader.inc' ;  
						 
					
						
							
								
									
										
										
										
											2013-01-19 13:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									echo  '<div class="user-bright smallPaddingContent">' ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-10-24 13:53:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									echo  " <form action= \" initsuff.php \"  method= \" post \" > \n " ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-18 08:19:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$container  =  new  htmlResponsiveRow (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$container -> add ( new  htmlOutputText ( _ ( " The following suffixes are missing in LDAP. LAM can create them for you. " )),  12 ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$container -> add ( new  htmlOutputText ( _ ( " You can setup the LDAP suffixes for all account types in your LAM server profile on tab  \" Account types \" . " )),  12 ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$container -> addVerticalSpacer ( '1rem' ); 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// print missing suffixes
 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 10:33:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									foreach  ( $newSuffixes  as  $newSuffix )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-18 08:19:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$container -> add ( new  htmlOutputText ( $newSuffix ),  12 ); 
							 
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-18 08:19:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$container -> addVerticalSpacer ( '2rem' ); 
							 
						 
					
						
							
								
									
										
										
										
											2010-10-24 13:53:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-11-18 08:19:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$buttonContainer  =  new  htmlGroup (); 
							 
						 
					
						
							
								
									
										
										
										
											2010-10-24 13:53:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$buttonContainer -> addElement ( new  htmlButton ( 'add_suff' ,  _ ( " Create " ))); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$buttonContainer -> addElement ( new  htmlButton ( 'cancel' ,  _ ( " Cancel " ))); 
							 
						 
					
						
							
								
									
										
										
										
											2017-09-17 10:33:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$buttonContainer -> addElement ( new  htmlHiddenInput ( 'new_suff' ,  implode ( " ; " ,  $newSuffixes ))); 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-18 08:19:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$container -> add ( $buttonContainer ,  12 ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-15 19:16:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									addSecurityTokenToMetaHTML ( $container ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-11 16:11:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-10-24 13:53:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$tabindex  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									parseHtml ( null ,  $container ,  array (),  false ,  $tabindex ,  'user' ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-11 16:11:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-08-21 09:43:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									echo  " </form><br> \n " ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-10-24 13:53:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									echo  " </div> \n " ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-12-23 16:21:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								include  __DIR__  .  '/../lib/adminFooter.inc' ;  
						 
					
						
							
								
									
										
										
										
											2003-07-28 18:36:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								?>