ldap AD using manager field

ldap AD using manager field

by Justin P -
Number of replies: 2
Hello,
I am trying to use the built in Manger entry in AD to move towards auto assigning parent role to students. The only problem is that the entry isn't just the name, it looks like "manager: CN=Test Guy,CN=Users,DC=TESTDOMAIN,DC=LOCAL" and I need to just strip out the name.
So I need to find where Moodle ldap pulls this value and use efficient code to strip out what I need. I'm not a super php programmer so any help would be greatly appreciated.
Average of ratings: -
In reply to Justin P

Re: ldap AD using manager field

by Justin P -
So here is what I came up with for php to strip out what I want.
$str = "ldap-pull";

$array1 = explode("=", $str);

$array2 = explode(",", $array1[1]);

$array3 = explode(" ", $array2[0]);

$fname = $array3[0];

$lname = $array3[1];

Now I have the supervisors first name ($fname) and last name ($lname) saved. I just now need to write a script that searches through the moodle database to find a name match and them add the appropriate role permissions in the database.
Anyone have any help they can give me on this? I don't fully understand how the role table works.
In reply to Justin P

Re: ldap AD using manager field

by Justin P -
I have create a php script with the help of Anthony Borrow that adds the supervisor role automatically. Please see discussion here - http://moodle.org/mod/forum/discuss.php?d=70539#p349495

To complete the entire automatic role creation I just need to find out where to add my code above that breaks apart the text pulled with LDAP before it is placed in the mdl_user table. Can anyone help with this?