Anyone out there using ActiveLDAP have an idea how I can accomplish
creating an object one level below a known base where we have a variable
item in the middle?
That first sentence doesn’t even make sense to me. Here’s what I want
to do: I have a user class that I use for managing users. Each user
gets a ou called addressbook (which in turn will contain sub-entries,
but we’re not worried about that) like so:
dn: [email protected],ou=Users,ou=OxObjects,dc=example,dc=com
uid: [email protected]
dn: ou=addr,[email protected],ou=Users,ou=OxObjects,dc=example,dc=com
objectClass: top
objectClass: organizationalUnit
ou: addr
dn:
uid=135,ou=addr,[email protected],ou=Users,ou=OxObjects,dc=example,dc=com
I want to create the ou=addr,[email protected],PREFIX entry each time
I create a user, but I can’t figure out how to get ActiveLDAP to let me
do that. I had tried doing something like creating another model like
this:
class Addr < ActiveLDAP::Base
ldap_mapping :dnattr => ‘ou=addr,uid’, :prefix => USER_PREFIX,
:classes => [
‘top’, ‘organizationalUnit’ ]
end
And modifying the base.rb code for ActiveLDAP with a goofy hack to allow
setting this sort of :dnattr value, but it picks up all the methods and
attributes of a user object, so I can’t quite do that… Here’s the ex
from base.rb:
# Break val apart if it is a dn
if val.match(/^ou=addr.*/i)
val = $1
elsif val.match(/^#{dnattr()}=([^,=]+),#{base()}$/i)
val = $1
elsif val.match(/[=,]/)
@@logger.info "initialize: Changing val from '#{val}' to ''
because it doesn’t match the DN."
val = ‘’
end
And before I start breaking this any furthor, I was wondering if someone
has already done this sort of thing.