Not sure whats wrong with this code but everytime I use it - it creates an account and a primary server but doesnt create any other smtp ProxyAddresses. Any ideas what could be wrong? I have removed my authentication details and other bits from the code below:
<?php
$requestedurl = $_GET["firstname"].$_GET["surname"];
// mkdir("//fpstaff//StaffHomeFolders//".$_GET['firstname'].".".$_GET['surname'], 0777);
// $path = "//fpstaff//StaffHomeFolders//".$_GET['firstname'].".".$_GET['surname'];
$user_name = $_GET['firstname'].".".$_GET['surname'];
// chown($path, $user_name);
?>
<?php
Function Add()
{
$ds = ldap_connect(""); // assuming the LDAP server is on this host
if ($ds) {
// bind with appropriate dn to give update access
$r = ldap_bind($ds, "CN=booboo,OU=Staff,OU=College Users,DC=namegoeshere,DC=co,DC=uk", "");
// prepare data
$info["cn"] = $_GET['firstname'].".".$_GET['surname'];
$info["sn"] = $_GET['surname'];
$info["mail"] = $_GET['firstname'].".".$_GET['surname']."@blabla.co.uk";
$info["proxyAddresses"] = "smtp:".$_GET['firstname'].".".$_GET['surname']."@blabla.co.uk";
$info["proxyAddresses"] = "CCMAIL:".$_GET['surname'].", ".$_GET['firstname']." at blabla";
$info["proxyAddresses"] = "X400:c=US;a= ;p=;o=;s=".$_GET['surname'].";g=".$_GET['firstname'];
$info["targetAddress"] = "SMTP:".$_GET['firstname'].".".$_GET['surname']."@blabla.co.uk";
$info["mailNickname"] = $_GET['firstname'].".".$_GET['surname'];
$info["homeMTA"] = "CN=Microsoft MTA,CN=MAIL,CN=Servers,CN=,CN=Administrative Groups,CN=,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=,DC=ac,DC=uk";
$info["displayName"] = $_GET['surname'].", ".$_GET['firstname'];
if ($_GET["telephone"] == "") {
$info["telephoneNumber"] = "1234";
}
else {
$info["telephoneNumber"] = $_GET["telephone"];
}
$info["department"] = $_GET['department'];
$info["objectClass"] = "user";
$info["homeMDB"] = "CN=Mailbox Store 4 (Staff),CN=Storage Group 3 (Staff),CN=InformationStore,CN=MAIL,CN=Servers,CN=,CN=Administrative Groups,CN=,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=,DC=ac,DC=uk";
$info["distinguishedName"] = "CN=".$_GET['firstname'].".".$_GET['surname']."=Staff,OU= Users,DC=,DC=ac,DC=uk";
$info["userCertificate"] = $_GET['firstname'].".".$_GET['surname'];
$info["msExchHomeServerName"] = "";
$info["userPrincipalName"] = $_GET['firstname'].".".$_GET['surname']."@bvlablaac.uk";
$info["name"] = $_GET['firstname'].".".$_GET['surname'];
$info["sAMAccountName"] = $_GET['firstname'].".".$_GET['surname'];
$info["countryCode"] = 0;
$info["codePage"] = 0;
$info["givenName"] = $_GET["firstname"];
$info["homeDirectory"] = "";
$info["homeDrive"] = "H:";
$info["description"] = date('l jS \of F Y h:i:s A');
$info["userPassword"] =
$info["userAccountControl"] = 544;
//mailboxes 1,2,3
$r = ldap_add($ds, "CN=".$_GET['firstname'].".".$_GET['surname'].", OU=Staff, OU=Users, DC=college, DC=ac, DC=uk", $info);
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
$group_name = "CN=All Staff,OU=Recipients,OU=Exchange 55,DC=,DC=ac,DC=uk";
$group_name2 = "CN=Staff,OU=Staff,OU= Users,DC=,DC=ac,DC=uk";
$group_info["member"] = "CN=".$_GET['firstname'].".".$_GET['surname'].",OU=Staff,OU=Users,DC=
,DC=ac,DC=uk";
$ds = ldap_connect("");
$r = ldap_bind($ds, "CN=,OU=Staff,OU=Users,DC=,DC=co,DC=uk", "");
ldap_mod_add($ds,$group_name,$group_info);
ldap_mod_add($ds,$group_name2,$group_info);
}
?>