Drupal LDAP to copy Win.Server.AD groups to roles

Submitted by Anonymous (not verified) on Wed, 01/20/2010 - 14:49

I could connect to Active Directory using following code or using Drupal's LDAP module. I could log in successfully but I could not create groups automagicly or Drupal does not copy Windows Groups to Drupal roles. Should I do that manually? I am very new to Drupal and LDAP.

$dn = "ou=sbsusers,ou=users,ou=mybusiness,dc=my_companyx,dc=local";

$attributes = array("displayname", "l", "description", "sAMAccountName", "memberOf");

$filter = "(cn=*)";

$ad = ldap_connect("ldap://") or die("Could not connect to AD!");

#ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3); // sometimes required

$bd = ldap_bind($ad,"my_usernamex@my_companyx.local","MyPasswordBlaBla") or die("Could not bind to AD!");

$result = ldap_search($ad, $dn, $filter, $attributes);

$entries = ldap_get_entries($ad, $result);

echo "< pre >".print_r($entries, 1)."< /pre >";

for ($i=0; $i<$entries["count"]; $i++)
#echo $entries[$i]["displayname"][0]."(".$entries[$i]["l"][0].")