Location: PHPKode > projects > Internet Task Management System > itms_mysql_build_0111/add_ldap_users_to_itms.php
<?php

/*
 * ITMS ValleyData source file version 1.0 May 11, 2001
 *
 * This file will go through the LDAP directory specified in config.php
 * and add all the user names to ITMS
 *
 *
 *
 * Internet Task Management System: An online system used for recording information about and assigning tasks and processes.
 * Copyright (C) 2001  ValleyData Programming Group
 *
 * 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
 *
 * See file named "gpl.txt" included with source code or
 * visit http://www.gnu.org/copyleft/gpl.txt on the internet.
 */

include("config.php");
include("toolbox.php");
include("error_handler.php");
include("db_tools.php");

if($key != $EXECUTE_KEY) // This is an aribtrary number defined in config.php that matches reminder.cron
{
    die("Bad key supplied for add_ldap_users_to_itms.php");
}

else // If the key is correct
{
    //get a list of all the ldap users and their emails
    $all_users_array = get_all_ldap_users();

    //foreach user:
    foreach($all_users_array as $user)
    {
        $newusername = $user["name"];
        $user_email = $user["email"];
        print("User's name: $newusername <br>\n");
        print("User's email: $user_email <br><br>\n");
        
        $query = "SELECT * FROM users WHERE name like '$newusername'";
        if(db_fetch_row(db_query($query))) // Check for duplicate user name
        {
            message_box("User name already exists!", "error");
            error_out("Couldn't add user with duplicate name: " . $newusername, "LOG_INFO");
        }
		else
		{
			$query = "INSERT INTO users (name, email) VALUES ('$newusername', '$user_email')";
			db_query($query) // Add the user to the database
		}
        
    }//end foreach user
}//end else

?>
Return current item: Internet Task Management System