Module: ActiveSambaLdap::SambaGroupEntry

Includes:
SambaEntry
Included in:
Group
Defined in:
lib/active_samba_ldap/samba_group_entry.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

SID_BUILTIN =

from librpc/ndr/security.h in Samba

"S-1-5-32"
DOMAIN_ADMINS_RID =

from source/include/rpc_misc.c in Samba

0x00000200
DOMAIN_USERS_RID =
0x00000201
DOMAIN_GUESTS_RID =
0x00000202
DOMAIN_COMPUTERS_RID =
0x00000203
LOCAL_ADMINS_RID =
0x00000220
LOCAL_USERS_RID =
0x00000221
LOCAL_GUESTS_RID =
0x00000222
LOCAL_POWER_USERS_RID =
0x00000223
LOCAL_ACCOUNT_OPERATORS_RID =
0x00000224
LOCAL_SYSTEM_OPERATORS_RID =
0x00000225
LOCAL_PRINT_OPERATORS_RID =
0x00000226
LOCAL_BACKUP_OPERATORS_RID =
0x00000227
LOCAL_REPLICATORS_RID =
0x00000228
DOMAIN_ADMINS_NAME =

from source/rpc_server/srv_util.c in Samba

"Domain Administrators"
DOMAIN_USERS_NAME =
"Domain Users"
DOMAIN_GUESTS_NAME =
"Domain Guests"
DOMAIN_COMPUTERS_NAME =
"Domain Computers"
WELL_KNOWN_RIDS =
[]
WELL_KNOWN_NAMES =
[]
TYPES =

from source/librpc/idl/lsa.idl in Samba

{
  "domain" => 2,
  "local" => 4,
  "builtin" => 5,
}

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SambaEntry

#ensure_samba_available, #remove_samba_availability, #samba_available?, #samba_object_classes

Class Method Details

.included(base) ⇒ Object



7
8
9
10
# File 'lib/active_samba_ldap/samba_group_entry.rb', line 7

def self.included(base)
  super
  base.extend(ClassMethods)
end

Instance Method Details

#change_gid_number(gid, allow_non_unique = false) ⇒ Object



101
102
103
104
105
106
# File 'lib/active_samba_ldap/samba_group_entry.rb', line 101

def change_gid_number(gid, allow_non_unique=false)
  result = super
  return result unless samba_available?
  rid = self.class.gid2rid(gid_number)
  change_sid(rid, allow_non_unique)
end

#change_gid_number_by_rid(rid, allow_non_unique = false) ⇒ Object



108
109
110
111
# File 'lib/active_samba_ldap/samba_group_entry.rb', line 108

def change_gid_number_by_rid(rid, allow_non_unique=false)
  assert_samba_available
  change_gid_number(self.class.rid2gid(rid), allow_non_unique)
end

#change_sid(rid, allow_non_unique = false) ⇒ Object



113
114
115
116
117
118
119
120
121
122
# File 'lib/active_samba_ldap/samba_group_entry.rb', line 113

def change_sid(rid, allow_non_unique=false)
  assert_samba_available
  if (LOCAL_ADMINS_RID..LOCAL_REPLICATORS_RID).include?(rid.to_i)
    sid = "#{SID_BUILTIN}-#{rid}"
  else
    sid = "#{self.class.configuration[:sid]}-#{rid}"
  end
  # check_unique_sid_number(sid) unless allow_non_unique
  self.samba_sid = sid
end

#change_type(type) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/active_samba_ldap/samba_group_entry.rb', line 129

def change_type(type)
  assert_samba_available
  normalized_type = type.to_s.downcase
  if samba4?
    self.group_type = ActiveDirectory::GroupType.resolve(normalized_type)
  else
    if TYPES.has_key?(normalized_type)
      type = TYPES[normalized_type]
    elsif TYPES.values.include?(type.to_i)
      # pass
    else
      # TODO: add available values
      raise ArgumentError, _("invalid type: %s") % type
    end
    self.samba_group_type = type.to_s
  end
end

#fill_default_values(options = {}) ⇒ Object



92
93
94
95
96
97
98
99
# File 'lib/active_samba_ldap/samba_group_entry.rb', line 92

def fill_default_values(options={})
  if samba_available?
    options = options.stringify_keys
    change_type(options["group_type"] || "domain") unless samba_group_type
    self.display_name ||= options["display_name"] || cn
  end
  super
end

#ridObject



124
125
126
127
# File 'lib/active_samba_ldap/samba_group_entry.rb', line 124

def rid
  assert_samba_available
  Integer(samba_sid.split(/-/).last)
end

#set_object_categoryObject



147
148
149
150
# File 'lib/active_samba_ldap/samba_group_entry.rb', line 147

def set_object_category
  _base = ActiveSambaLdap::Base.base
  self.object_category = "cn=Group,cn=Schema,cn=Configuration,#{_base}"
end