Code: Alles auswählen
<html>
<head>
<link rel = "stylesheet" type = "text/css" href = "stylesheets/stylesheet.css">
<title>OwnCloud Registration</title>
</head?
<body>
<h1> OwnCloud Registration </h1>
<hr>
<?php
$cn = htmlspecialchars($_POST['username']);
$givenName = htmlspecialchars($_POST['firstname']);
$surname = htmlspecialchars($_POST['lastname']);
$mail = ($_POST['mail']);
$password = htmlspecialchars($_POST['passwort']);
$klasse = htmlspecialchars($_POST['klasse']);;
$sub = substr($givenName ,0,1);
$userid = $sub.$surname ;
$homeDirectory = "/home/users/$userid";
$gidNummer = 502;
echo "Benutzer: $cn " . '<br>';
$ds = ldap_connect("localhost") or die ("Could not connect to LDAP Server");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($ds) {
$r = ldap_bind($ds,"cn=admin,dc=example,dc=com","test1");
$info["cn"] = $cn;
$info["givenName"] = $givenName;
$info["sn"] = $surname;
$info["mail"] = $mail;
$info["userPassword"] = $password;
$info["businessCategory"] = $klasse;
$info["homeDirectory"] = $homeDirectory;
$info["uid"] = $givenName;
$info["uidNumber"] = 1020;
$info["gidNumber"] = 502;
$info["objectClass"] = "inetOrgPerson";
$info["objectClass"] = "posixAccount";
$info["objectClass"] = "top";
$r = ldap_add($ds,"cn=$cn,cn=user,dc=example,dc=com",$info);
$sr = ldap_search($ds,"dc=example,dc=com","cn=$cn");
$info = ldap_get_entries($ds,$sr);
echo "Der Benutzer:<span class='result'> " . $info[0]["dn"] . "</span> wurde hinzugefügt der Administrator kümmert sich um die freischaltung. <br>";
}
ldap_close($ds);
?>
<hr>
</body>
</html>