On Sun, 26 Nov 2000, Corisen wrote:

> I'm most probably be using PHP to perform all LDAP administration.

I'd like to make one comment: PHP is a great web scripting language, but I
find it awkward as a system administration language. You will be able to
perform almost all operations using PHP, but it will be awkward to fire up
a web browser and code a PHP page to perform a simple administration task.

One of the advantages of LDAP is its widespread support. There are at
least two C APIs for Linux, 2 perl APIs, a Python API, and a couple of
Java APIs. I'd recommend you acquaint yourself  with at least one of the
Perl or Python APIs, and you might find that it only takes one or two
lines of Perl or Python to accomplish what would take several in PHP -- or
vice versa for that matter. Right tools for the right job.

> But if I don't change the "o=department" in the DN for all child entries
> when the department name changes, then would I still be able to
> perform a ldap search using the new department name as a base?
>
> i.e. can i still perform:
> ldapsearch -b "o=newdepartment, dc=company, dc=com" "uid=*"?
>
> say if I really want to change/update to "o=newdepartment" in DN
> for all child entries so that there's no obsolete info in the ldap
> database, can the ldapmodrrn be used also? Any idea if PHP API
> can change the dn of an entry?

Remember that a DN is a directory address, so if you change the parent,
you don't need to change the children. If you need to change the children
attributes, that will most likely need to be done recursively, though.

Changing a DN is really just a matter of renaming a parent entry, which is
what modrdn does. I don't know if PHP supports modrdn, but if i doesn't
your choice is to copy (recursively) to a new tree and delete
(recursively).

> > if i use only (without the o=department in dn):
> > dn: uid=username, dc=company, dc=com
> > objectclass....
> > o: department
> > ..... (other attributes/values)
> > can i query the ldap database and return only unique values(one value)
> for
> > each department names?
> > what is the command to do so?
>
> This is easy with the shell tool. The command:
>
>   ldapsearch -b 'base dn' '(objectclass=organization)' o
>
> will retrieve all 'o' attribute values from all objects of class
> 'organization'.
>
> I tried the following:
> 1. created a dn: dc=company, dc=com entry
> 2. created a few users with dn: uid=username, dc=company, dc=com (note i'm
> trying without the o=department in the DN)
>
> but when i perform a "ldapsearch -b "dc=company,dc=com"
> "objectclass=organization" o, it will return the repeated departments of
> all entries:
>
> uid=user1, dc=company, dc=com
> o=department1
>
> uid=user2, dc=company, dc=com
> o=department2
>
> uid=user3, dc=company, dc=com
> o=department1 <---repeated
>
> uid=user4, dc=company, dc=com
> o=department2 <---repeated
>
> Actually, I'm trying to get only 1 value for each department:
> o=department1
> o=department2
>
> Any idea if it's possible using command line tool or using PHP?

Something is most likely wrong with your data. Rarely would you have an
object that had both a uid and was a member of objectclass=organization.
Here is probably what your LDIF *should* look like:

dn: o=department1, dc=company, dc=com
objectclass: top
objectclass: organization
o: department1

dn: o=department2, dc=company, dc=com
objectclass: top
objectclass: organization
o: department2

dn: uid=user1, dc=company, dc=com
objectclass: top
objectclass: account
objectclass: organizationalPerson
uid: user1
o: department1
cn: Joe Smith

dn: uid=user2, dc=company, dc=com
objectclass: top
objectclass: account
objectclass: organizationalPerson
uid: user2
o: department2
cn: Jane Smith

...

The search with filter 'objectclass=organization' will only retrieve the
objects of class organization, so you will only get department1 and
department2.

thornton



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to