Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Explode() array issue

Status
Not open for further replies.

GigaG

Technical User
Aug 28, 2007
83
US
Below is my config. I am connecting through php to AD LDAP server for authentication. the ldap part works like a dream. I used the explode function to drop all the excess baggage with the user to only get me the display name, but I am unable to turn this into an array or some other way to sort the info. I know explode is suppose to make the variable an array, but i think because i'm in a loop, it is erasing the data


<?

/******globals needed for included pages***/

global $displayname;
//$user =& JFactory::getUser();

/*************Ens of globals needed for included pages***/


$dn = "CN=Sales_Managers,OU=CINET,OU=Carousel Everyone,DC=CHARLESTOWN,DC=CAROUSELINDUSTRIES,DC=com";

$attributes = array("displayname","member", "1");

$filter = "(cn=*)";

$ad = ldap_connect("10.0.25.250")
or die("Couldn't connect to AD!");

ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ad, LDAP_OPT_SIZELIMIT, 500);

$bd = ldap_bind($ad,"administrator@charlestown.carouselindustries.com","c@r0us3L")
or die("Couldn't bind to AD!");

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

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

// Specify Variable and begin
$a=0;

//Create your loop for $a
do
{

//Grab all the Members array of the user logged in and store
$member=$entries[0]["member"][$a];


//$member=$entries[0]["member"][0];
// Explode $members to grab only the CN name
$member1=explode ("CN=",$member);
$member2=explode (",",$member1[1])

//echo $member . "<br>";
//echo $member1[1] . "<br>";
$members3[$a]=array($members2[0]);
//echo $members3;
echo $member2[0] . "<br>";
print_r ($members3);
echo $a;
$a++;
}
while($a<50);
ldap_unbind($ad);
?>

MCP ACA-I CTP
 
I also would like to add tat i did a print_r($member2); and got this....

Array ( [0] => Gregg Coleman [1] => OU=ALB Users [2] => OU=ALB Office [3] => OU=Carousel Everyone [4] => DC=CHARLESTOWN [5] => DC=CAROUSELINDUSTRIES [6] => DC=com )

Array ( [0] => Chris Jenkins [1] => OU=ALB Users [2] => OU=ALB Office [3] => OU=Carousel Everyone [4] => DC=CHARLESTOWN [5] => DC=CAROUSELINDUSTRIES [6] => DC=com )

Ultamitly, I would like to take the names which are Array[0] and put them in an array for sorting so that I put them in a dropdown box

Thanks

MCP ACA-I CTP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top