Drupal LDAP to copy Win.Server.AD groups to roles
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.
<?php
$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://127.0.0.1") 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].")<br />";
}
ldap_unbind($ad);
Similar entries
- Drupal and LDAP
- Delete all spam node entries of a spesific user on a Drupal site with PHP
- 'Similar entries' block cannot be changed on Drupal
- Drupal warning: array_filter()
- 'Similar entries' block cannot be saved
- Replace string in big database or large text file
- Let your visitors run Drupal cron for you
- You have too many groups. You must leave one to join this one.
- Drupal fieldset default expanded not collapsed
- PHP Block for Custom Role under Drupal 6
- Simple Hello World Module for Drupal 6
- How to add very long text to Drupal 6x?
- Drupal 6 vs. Joomla 1.5 (2009)
- Suhosin blocks Drupal Modules
- Drupal problem with inline style <p style=""> and <br />
- Backup all MySQL databases automagicly with the PHP admin script
- Fix Google Adsense Search and Drupal Conflict
- Recreate all teasers on Drupal
- How to add new sites to Drupal's service links module?
- Why Google-PR gives Drupal 8, Joomla 9 and Phpnuke 5?

Post new comment