Welcome Guest, Not a member yet? Register   Sign In
Problem with Custom config file
#1

[eluser]Unknown[/eluser]
I'm trying to create a custom config file for active directory but I keep getting the same error no matter what I try. I read the previous topics on here about my problem, but none of the solutions seemed to help me. The error is "Your ad.php file does not appear to contain a valid configuration array."

./system/application/config/ad.php
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| ACTIVE DIRECTORY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your active directory.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
|    ['hostname'] The hostname of your ldap server.
|    ['basedn'] The base domain name for the users
|    ['filter'] The filter to search in active directory
|    ['port'] The port to connect to ldap server
|
| The $active_group variable lets you choose which connection group to
| make active.  By default there is only one group (the "default" group).
*/
include('swe.php');

$active_group = $environment;
$ad = array();

$ad['dev']['hostname'] = "172.29.97.12";
$ad['dev']['basedn'] = "OU=EMPLOYEES, OU=xxxx Users, DC=SE, DC=COM";
$ad['dev']['filter'] = "sAMAccountName=";
$ad['dev']['port'] = "389";

$ad['prod']['hostname'] = "xx.xx.com";
$ad['prod']['basedn'] = "OU=EMPLOYEES, OU=xxxx Users, DC=AD, DC=xxxx, DC=COM";
$ad['prod']['filter'] = "sAMAccountName=";
$ad['prod']['port'] = "389";


/* End of file ad.php */
/* Location: ./system/application/config/ad.php */

autoload.php
Code:
/*
| -------------------------------------------------------------------
|  Auto-load Config files
| -------------------------------------------------------------------
| Prototype:
|
|    $autoload['config'] = array('config1', 'config2');
|
| NOTE: This item is intended for use ONLY if you have created custom
| config files.  Otherwise, leave it blank.
|
*/

$autoload['config'] = array('ad');

swe.php
Code:
<?php
$environment="dev";
?>
#2

[eluser]Cristian Gilè[/eluser]
A note from the userguide:

Quote:If you do create your own config files use the same format as the primary one, storing your items in an array called $config

The primary one is the main config.php file. $ad is not a valid array name.

Cristian Gilè
#3

[eluser]Unknown[/eluser]
Hmm... seems your right, I was using the database.php config as a template. Thanks for your help, but just out of my sheer curiosity, why does database.php, routes.php,smileys.php etc.. get away with this and I can't?

Code:
$db['dev']['hostname'] = "172.29.97.7";
$db['dev']['username'] = "xxxx";
$db['dev']['password'] = "xxxx";
$db['dev']['database'] = "code_igniter";
$db['dev']['dbdriver'] = "postgre";
$db['dev']['dbprefix'] = "";
$db['dev']['pconnect'] = TRUE;
$db['dev']['db_debug'] = TRUE;
$db['dev']['cache_on'] = FALSE;
$db['dev']['cachedir'] = "";
$db['dev']['char_set'] = "utf8";
$db['dev']['dbcollat'] = "utf8_general_ci";
#4

[eluser]Cristian Gilè[/eluser]
This is a convention.

Cristian Gilè
#5

[eluser]tomcode[/eluser]
Quote:... why does database.php, routes.php,smileys.php etc.. get away with this and I can’t?

The above mentioned use their own routine to load the file, the moment You load using this->load->config() You need to have a $config variable declared, here the example for the smileys :
Code:
/**
* Get Smiley Array
*
* Fetches the config/smiley.php file
*
* @access    private
* @return    mixed
*/
if ( ! function_exists('_get_smiley_array'))
{
    function _get_smiley_array()
    {
        if ( ! file_exists(APPPATH.'config/smileys'.EXT))
        {
            return FALSE;
        }

        include(APPPATH.'config/smileys'.EXT);

        if ( ! isset($smileys) OR ! is_array($smileys))
        {
            return FALSE;
        }

        return $smileys;
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB