PHP 8.5.0 Alpha 4 available for testing

Voting

: min(zero, two)?
(Example: nine)

The Note You're Voting On

Baumkuchen.TH
6 years ago
Create Group in Active Directory

<?php
$ds
= ldap_connect("IP-server/localhost");
$base_dn = "CN=Group name,OU=Organization Unit,DC=Domain-name,DC=com";//distinguishedName of group

if ($ds) {
// bind with appropriate dn to give update access
ldap_bind($ds, "CN=Administrator,OU=Organization Unit,DC=Domain-name,DC=com", "some-password");

//Add members in group
$member_array = array();
$member_array[0] = "CN=Administrator,OU=Organization Unit,DC=Domain-name,DC=com";
$member_array[1] = "CN=User,OU=Organization Unit,DC=Domain-name,DC=com";

$entry["cn"] = "GroupTest";
$entry["samaccountname"] = "GroupTest";
$entry["objectClass"] = "Group";
$entry["description"] = "Group Test!!";
$entry["member"] = $member_array;
$entry["groupType"] = "2";//GroupType="2" is Distribution / GroupType="1" is Security

ldap_add($ds,$base_dn,$entry);

ldap_close($ds);
} else {
echo
"Unable to connect to LDAP server";
}
?>

<< Back to user notes page

To Top