Class: Tcs::Ldap::Group
- Inherits:
-
Object
- Object
- Tcs::Ldap::Group
- Defined in:
- lib/tcs/ldap/group.rb
Overview
models an LDAP group specifier, like CN=pbadmins,OU=Security Groups,OU=Group Accounts,DC=containerstore,DC=com as an array of two-element arrays, with lowest-level nodes being first in the array [
['CN', 'pbadmins'],
['OU', 'Security Groups'],
['OU', 'Group Accounts'],
['DC', 'containerstore'],
['DC', 'com']
]
Instance Method Summary collapse
- #cn ⇒ Object
-
#initialize(group_string) ⇒ Group
constructor
A new instance of Group.
Constructor Details
#initialize(group_string) ⇒ Group
Returns a new instance of Group.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tcs/ldap/group.rb', line 14 def initialize(group_string) @original_string = group_string # CN=pb\, admins,OU=Security Groups\=good,OU=Group Accounts,DC=containerstore,DC=com string_with_escaped_commas_replaced = group_string.gsub(/\\,/, ";;") # CN=pb$$ admins,OU=Security Groups\=good,OU=Group Accounts,DC=containerstore,DC=com nodes_with_commas_replaced = string_with_escaped_commas_replaced.split(",") # ['CN=pb$$ admins', 'OU=Security Groups\=good', 'OU=Group Accounts', 'DC=containerstore', 'DC=com'] node_strings = nodes_with_commas_replaced.collect { |n| n.gsub(/;;/, ",") } # ['CN=pb, admins', 'OU=Security Groups\=good', 'OU=Group Accounts', 'DC=containerstore', 'DC=com'] node_strings_with_equals_replaced = node_strings.collect { |n| n.gsub(/\\=/, ";;") } # ['CN=pb, admins', 'OU=Security Groups$$good', 'OU=Group Accounts', 'DC=containerstore', 'DC=com'] nodes_with_equals_replaced = node_strings_with_equals_replaced.collect { |n| n.split("=") } # [['CN', 'pb, admins'], ['OU', 'Security Groups$$good'], # ['OU', 'Group Accounts'], ['DC', 'containerstore'], ['DC', 'com']] @nodes = nodes_with_equals_replaced.collect { |n| [n.first, n.last.gsub(/;;/, "=")] } end |
Instance Method Details
#cn ⇒ Object
31 32 33 |
# File 'lib/tcs/ldap/group.rb', line 31 def cn @nodes.first.last end |