Here is my PHP script to do the same thing with AD. Hopefully the script
wont get too mangled with linebreaks.

#!/usr/bin/php
<?php
include "db.php";

$binddn = "your_bind_dn";
$bindpw = "your_bind_password";
$basedn = "your_base_dn";
$ldaphost = "your_domain_controller";

$get_displayNames = "ldapsearch -x -h ${ldaphost} -D \"$binddn\" -w
$bindpw -b \"$basedn\" objectCategory=Person | grep \"^cn: \" | sed
s/^cn:\ //g | grep -v User | grep -v Admin | sort | tr \"\\n\" \",\"";
$results = shell_exec($get_displayNames);

$all_displayNames = explode(",", $results);
foreach ($all_displayNames as $collection_owner_displayName) {
        if ($collection_owner_displayName) {
                $get_collection_owner_sAMAccountName = "ldapsearch -x -h
${ldaphost} -D \"$binddn\" -w $bindpw -b \"$basedn\" displayName=
\"$collection_owner_displayName\" | grep \"^mail: \" | sed s/^mail:
\ //g";
                if ($collection_owner_sAMAccountName =
strtolower(rtrim(shell_exec($get_collection_owner_sAMAccountName)))) {
                        foreach ($all_displayNames as $jid_displayName)
{
                                if ($jid_displayName) {
                                        $jid_displayName =
mysql_real_escape_string($jid_displayName);
                                        $get_jid_sAMAccountName =
"ldapsearch -x -h ${ldaphost} -D \"$binddn\" -w $bindpw -b \"$basedn\"
displayName=\"$jid_displayName\" | grep \"^mail: \" | sed s/^mail:
\ //g";
                                        if ($jid_sAMAccountName =
strtolower(rtrim(shell_exec($get_jid_sAMAccountName)))) {
                                                // Insert statement is
here... whew
                                                if
(!($collection_owner_sAMAccountName == $jid_sAMAccountName)) {
                                                        $query = "INSERT
into `roster-items` (`collection-owner`, jid, name, `to`, `from`, `ask`)
VALUES ('$collection_owner_sAMAccountName', '$jid_sAMAccountName',
'$jid_displayName', 1, 1, 0)";
                                                        echo "$query\n";

mysql_query($query) or die(mysql_error());
                                                        echo "\n";
                                                }
                                        }

                                }
                        }
                }
        }
}
?>
-----Original Message-----
From: jonhattan <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: [jabberd2] Auto populate a roster via LDAP
Date: Thu, 10 Apr 2008 14:32:12 -0700



Gary Danko escribió:
> I have implemented jabberd2 with LDAP authentication. I'd like to
> auto-populate the roster so all employees are in the buddy list for
each
> client.
>
> Could someone guide me to a howto or some documentation for something
> like this?
> Thanks
> Gary
>
>

Hi Gary,

I've acomplish this with a little script of my own. I create a ldap
entry for the new jabber account and afterwards insert the relationship
in the storage backend --postgres-- (the new account as a contact for
each existent account and each existent account as a contact for the new
account). Tables roster-items and roster-groups are involved.

regards,
jonhattan


--
To unsubscribe send a mail to [EMAIL PROTECTED]




--
To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to