Module: ActiveDirectory::Member

Included in:
Group, User
Defined in:
lib/bsb_active_directory/member.rb

Instance Method Summary collapse

Instance Method Details

#join(group) ⇒ Object

Add the member to the passed Group object. Returns true if this object is already a member of the Group, or if the operation to add it succeeded.



38
39
40
41
# File 'lib/bsb_active_directory/member.rb', line 38

def join(group)
  return false unless group.is_a?(Group)
  group.add(self)
end

#member_of?(usergroup) ⇒ Boolean

Returns true if this member (User or Group) is a member of the passed Group object.

Returns:

  • (Boolean)


27
28
29
30
31
32
# File 'lib/bsb_active_directory/member.rb', line 27

def member_of?(usergroup)
  group_dns = memberOf
  return false if group_dns.nil? || group_dns.empty?
  # group_dns = [group_dns] unless group_dns.is_a?(Array)
  group_dns.map(&:dn).include?(usergroup.dn)
end

#unjoin(group) ⇒ Object

Remove the member from the passed Group object. Returns true if this object is not a member of the Group, or if the operation to remove it succeeded.



48
49
50
51
# File 'lib/bsb_active_directory/member.rb', line 48

def unjoin(group)
  return false unless group.is_a?(Group)
  group.remove(self)
end