class ASF::Service
Access to LDAP
services (ou=groups,ou=services,dc=apache,dc=org
)
Attributes
Date this committee was initially created in LDAP
.
Date this committee was last modified in LDAP
.
Public Class Methods
Source
# File lib/whimsy/asf/ldap.rb, line 1469 def self.listcns(filter='cn=*') ASF.search_one(base, filter, 'cn').flatten end
return a list of services (cns only), from LDAP
.
Source
# File lib/whimsy/asf/ldap.rb, line 1493 def self.preload Hash[ASF.search_one(base, 'cn=*', %w(dn member memberUid modifyTimestamp createTimestamp)).map do |results| cn = results['dn'].first[/^cn=(.*?),/, 1] service = self.find(cn) service.modifyTimestamp = results['modifyTimestamp'].first # it is returned as an array of 1 entry service.createTimestamp = results['createTimestamp'].first # it is returned as an array of 1 entry members = results['member'] || results['memberUid'].map {|k| ASF::Person.dn(k)} || [] service.members = members [service, members] end] end
fetch dn
, member
, modifyTimestamp
, and createTimestamp
for all services in LDAP
. N.B. some services have memberUid rather than member entries
Public Instance Methods
Source
# File lib/whimsy/asf/ldap.rb, line 1551 def add(people) @members = nil # force fresh LDAP search people = (Array(people) - members).map(&:dn) return if people.empty? # TODO: how to handle memberUid service groups ? ASF::LDAP.modify(self.dn, [ASF::Base.mod_add('member', people)]) ensure @members = nil end
add people to this service in LDAP
Source
# File lib/whimsy/asf/ldap.rb, line 1482 def base if dn dn.sub(/^cn=.*?,/, '') else super end end
base subtree for this service
ASF::Base::base
Source
# File lib/whimsy/asf/ldap.rb, line 1474 def dn return @dn if @dn dns = ASF.search_subtree(self.class.base, "cn=#{name}", 'dn') @dn = dns.first.first unless dns.empty? @dn end
Designated Name from LDAP
Source
# File lib/whimsy/asf/ldap.rb, line 1530 def memberids members = weakref(:members) do results = ASF.search_one(base, "cn=#{name}", ['member', 'memberUid']).first results['member'] || results['memberUid'].map {|k| ASF::Person.dn(k)} || [] end members.map {|uid| uid[/uid=(.*?),/, 1]} end
list of memberids for this service in LDAP
N.B. some services have memberUid rather than member entries
Source
# File lib/whimsy/asf/ldap.rb, line 1519 def members members = weakref(:members) do results = ASF.search_one(base, "cn=#{name}", ['member', 'memberUid']).first results['member'] || results['memberUid'].map {|k| ASF::Person.dn(k)} || [] end members.map {|uid| Person.find uid[/uid=(.*?),/, 1]} end
list of members for this service in LDAP
N.B. some services have memberUid rather than member entries
Source
# File lib/whimsy/asf/ldap.rb, line 1513 def members=(members) @members = WeakRef.new(members) end
setters for members. Should only be called by preload N.B. Do not dereference @members directly; use weakref(:members) instead
Source
# File lib/whimsy/asf/ldap.rb, line 1540 def remove(people) @members = nil # force fresh LDAP search people = (Array(people) & members).map(&:dn) return if people.empty? # TODO: how to handle memberUid service groups ? ASF::LDAP.modify(self.dn, [ASF::Base.mod_delete('member', people)]) ensure @members = nil end
remove people from this service in LDAP