lib/whimsy/asf/ldap.rb in whimsy-asf-0.0.55 vs lib/whimsy/asf/ldap.rb in whimsy-asf-0.0.56

- old
+ new

@@ -285,23 +285,40 @@ def self.list(filter='cn=*') ASF.search_one(base, filter, 'cn').flatten end + def dn + "cn=#{id},#{self.class.base}" + end + def members ASF.search_one(base, "cn=#{name}", 'member').flatten. map {|uid| Person.find uid[/uid=(.*?),/,1]} end + + def remove(people) + people = Array(people).map(&:dn) + mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_DELETE, 'member', people) + ASF.ldap.modify(self.dn, [mod]) + end + + def add(people) + people = Array(people).map(&:dn) + mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_ADD, 'member', people) + ASF.ldap.modify(self.dn, [mod]) + end end module LDAP def self.bind(user, password, &block) dn = ASF::Person.new(user).dn if block ASF.ldap.bind(dn, password, &block) else ASF.ldap.bind(dn, password) end + ASF.init_ldap end # select LDAP host def self.host # try whimsy config