You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.
Warning: ldap_add(): Add: Operations error in C:\inetpub\wwwroot\vendor\adldap2\adldap2\src\Connections\Ldap.php on line 354
Steps To Reproduce:
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
// Construct new Adldap instance.
$ad = new Adldap\Adldap();
$connectionName = 'wolfnet-computing';
// Create a configuration array.
$config = [
// An array of your LDAP hosts. You can use either
// the host name or the IP address of your host.
'hosts' => ['xxxx.wolfnet.local'],
// The base distinguished name of your domain to perform searches upon.
'base_dn' => 'dc=wolfnet,dc=local',
// The account to use for querying / modifying LDAP records. This
// does not need to be an admin account. This can also
// be a full distinguished name of the user account.
'username' => 'xxxx@wolfnet.local',
'password' => 'xxxx',
// Optional Configuration Options
'account_suffix' => '@wolfnet.local',
'port' => 636,
'use_ssl' => true,
];
$ad->addProvider($config, $connectionName);
$ad->setDefaultProvider($connectionName);
$provider = $ad->getDefaultProvider();
$username = sanitizeUserData($_POST["user"]);
$password = sanitizeUserData($_POST["password"]);
$password2 = sanitizeUserData($_POST["password2"]);
$group = sanitizeUserData($_POST["group"]);
$name = sanitizeUserData($_POST["name"]);
$email = sanitizeUserData($_POST["email"]);
$jobTitle = sanitizeUserData($_POST["jobTitle"]);
try {
$user = $provider->make()->user();
$user->dn = $user->getDnBuilder()->addOu('Users');
$user->samAccountName = $username;
$user->cn = $name;
$user->password = $password;
$user->mail = $email;
// Save the user.
if ($user->save()) { // << ERROR HERE
$user->setCompany($siteCompany);
// Enable the new user (using user account control).
$user->setUserAccountControl(512);
if(!$user->save()) {
echo 'Error saving password';
exit();
}
} else {
echo $provider->getConnection()->getLastError();
echo '<br>User couldn\'t be created in AD!<br>';
exit();
}
// All done! An enabled user will be created and is ready for use.
if ($group == 'admins') {
$groupObj = $provider->search()->find('Domain Admins');
} else {
$groupObj = $provider->search()->find('Domain Users');
}
print_r($groupObj);
if (!$groupObj->addMember($user)) {
echo 'User wasn\'t added to group!';
exit();
}
} catch (\Adldap\Auth\BindException $e) {
echo 'LDAP Bind error!';
}
echo 'AD User created!';`
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description:
Warning: ldap_add(): Add: Operations error in C:\inetpub\wwwroot\vendor\adldap2\adldap2\src\Connections\Ldap.php on line 354
Steps To Reproduce:
The text was updated successfully, but these errors were encountered: