Created
January 7, 2011 17:19
-
-
Save airways/769764 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!$account_exists) // user doesn't exist in exp_members table, so we will create an EE account | |
{ | |
$this->debug_print("Using LDAP for account creation..."); | |
$unique_id = $FNS->random('encrypt'); | |
$join_date = $LOC->now; | |
$sql = "INSERT INTO exp_members SET ". | |
"username = '$given_username', ". | |
"password = '$encrypted_password', ". | |
"unique_id = '$unique_id', ". | |
"group_id = '5', ". | |
"screen_name = '{$user_info['cn'][0]}', ". | |
"email = '{$user_info['mail'][0]}', ". | |
"ip_address = '0.0.0.0', ". | |
"join_date = '$join_date', ". | |
"language = 'english', ". | |
"timezone = 'UTC', ". | |
"time_format = 'us'"; | |
$this->debug_print("Inserting user with SQL: $sql"); | |
$query = $DB->query($sql); | |
$member_id = $DB->insert_id; | |
if ($member_id > 0) // update other relevant fields | |
{ | |
$sql = "UPDATE exp_members SET photo_filename = 'photo_$member_id.jpg', photo_width = '90', photo_height = '120'"; | |
$query = $DB->query($sql); | |
$DB->query("INSERT INTO exp_member_data SET member_id = $member_id"); | |
$DB->query("INSERT INTO exp_member_homepage SET member_id = $member_id"); | |
$STAT->update_member_stats(); | |
ini_set('SMTP', $this->settings['mail_host']); | |
$headers = 'From: noreply@ncsoft.com' . "\r\n" . | |
'X-Mailer: PHP/' . phpversion(); | |
$success = mail($this->settings['admin_email'], | |
"A new member, '$given_username', has been registered on http://{$_SERVER['HTTP_HOST']}", | |
"This is a message from the ExpressionEngine LDAP authentication system.\n\nPlease log in to http://{$_SERVER['HTTP_HOST']} and update their member group, profile and 'people' weblog entry for user, '$given_username'.", | |
$headers); | |
} | |
else | |
{ | |
exit("Could not create user account for $given_username<br/>\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment