i think i'm following directions, the ldap search should check the uid for the unique value. i've created two profile fields profile_ou and profile_description that i had assumed might get filled in automagically... any help or an example would be great, thanks

CommentFileSizeAuthor
#1 Screen shot 2011-06-15 at 4.55.20 PM.png562.59 KBalibama

Comments

alibama’s picture

StatusFileSize
new562.59 KB

fyi instead of it working i get the following errror

warning: ldap_search() [function.ldap-search]: Search: Bad search filter in /home/www/vhosts/intranet.hsl.virginia.edu/sites/all/modules/pubcookie/pubcookie.module on line 370.
warning: ldap_get_entries(): supplied argument is not a valid ldap result resource in /home/www/vhosts/intranet.hsl.virginia.edu/sites/all/modules/pubcookie/pubcookie.module on line 372.

jvandyk’s picture

It looks to me, from your screenshot, that your LDAP Base DN is wrong.

alibama’s picture

just to be clear i'm certain that it's correct...
here's a code snippet i'm using to test ldap


    $host = "ldap.virginia.edu"; 
 
    // Who are we looking for? 
    $dn = "o=University of Virginia,c=US"; 
    $user = "uid=adp6j"; //this info'll be dynamic later... am testing it against my uid to start with


    // Connect to the LDAP server 
    $connection = ldap_connect($host) 
                  or die("Can't establish LDAP connection") ; 
 
    ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3); 
 
    // Bind to the LDAP server 
    ldap_bind($connection) or die("Can't bind to the server."); 
 
    // Retrieve the desired information 
    $results = ldap_search($connection, $dn, $user); 
    $info = ldap_get_entries($connection, $results);
    // Output the Group and Full Name 
    printf("Group: %s <br />", $info[ 0] ["ou"][ 0] ); 
    printf("Affiliation: %s <br />", $info[ 0] ["description"][ 0] ); 
 
    // Close the connection 
    ldap_unbind($connection); 

this returns
Group: Hs-Health Sciences Library
Affiliation: Staff
without errors... my next attempt is to add these fields using rules with custom php... not quite as nice... it'll be fine as long as it works :)

alibama’s picture

well fwiw here's the php for the triggered rule - just created a rule to take action when a new user is created

 $host = "ldap.virginia.edu";  
    // Who are we looking for? 
    $dn = "o=University of Virginia,c=US"; 
    $user = "uid=" . $account->name; 
    // Connect to the LDAP server 
$connection = ldap_connect($host) 
                  or die("Can't establish LDAP connection") ; 
 
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3); 
 
    // Bind to the LDAP server 
    
ldap_bind($connection) or die("Can't bind to the server."); 
 
    // Retrieve the desired info

$results = ldap_search($connection, $dn, $user); 
$info = ldap_get_entries($connection, $results);

    // Insert the group name (ou) and description (description) into the profile... the category 'ldap info' is just  
    // the group for the fields in our particular profile setup

$edit = array('profile_ou'=>$info[0]["ou"][0],'profile_description'=>$info[0]["description"][0]);
user_save((object) array('uid'=>$account->uid), $edit, 'ldap info');

    // Close the connection 
    ldap_unbind($connection);
jvandyk’s picture

Status: Active » Closed (won't fix)

7.x-2.x now maps LDAP to Drupal fields that are assigned to users.