From 14a07014f56f0d0ec5327f312290e10a464ba26d Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Fri, 13 Nov 2015 13:22:12 +0100 Subject: [PATCH] added memberof? method to user class --- lib/active_directory/user.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/active_directory/user.rb b/lib/active_directory/user.rb index 6fcd6e7..51c1297 100644 --- a/lib/active_directory/user.rb +++ b/lib/active_directory/user.rb @@ -79,6 +79,14 @@ def groups @groups ||= Group.find(:all, :distinguishedname => @entry[:memberOf] ) end + # + # Returns true if User object is member of Group object. + # group is a dn of a group + # + def memberof? + self["memberof"].map(&:dn).include?(group) + end + # # Returns an array of User objects that have this # User as their manager.