lib/active_samba_ldap/configuration.rb in activesambaldap-0.0.7 vs lib/active_samba_ldap/configuration.rb in activesambaldap-0.0.8
- old
+ new
@@ -97,12 +97,14 @@
user_home_drive user_logon_script mail_domain
skeleton_directory
default_user_gid default_computer_gid
- default_max_password_age)
+ default_max_password_age
+ samba4)
+
class << self
def required_variables
@required_variables ||= compute_required_variables
end
@@ -204,20 +206,37 @@
def method
:plain
end
def users_suffix
- retrieve_value_from_smb_conf(/ldap\s+user\s+suffix/i) || "ou=Users"
+ suffix = retrieve_value_from_smb_conf(/ldap\s+user\s+suffix/i)
+ return suffix if suffix
+ if self[:samba4]
+ "cn=Users"
+ else
+ "ou=Users"
+ end
end
def groups_suffix
- retrieve_value_from_smb_conf(/ldap\s+group\s+suffix/i) || "ou=Groups"
+ suffix = retrieve_value_from_smb_conf(/ldap\s+group\s+suffix/i)
+ return suffix if suffix
+ if self[:samba4]
+ "cn=Users"
+ else
+ "ou=Groups"
+ end
end
def computers_suffix
- retrieve_value_from_smb_conf(/ldap\s+machine\s+suffix/i) ||
+ suffix = retrieve_value_from_smb_conf(/ldap\s+machine\s+suffix/i)
+ return suffix if suffix
+ if self[:samba4]
+ "cn=Computers"
+ else
"ou=Computers"
+ end
end
def idmap_suffix
retrieve_value_from_smb_conf(/ldap\s+idmap\s+suffix/i) || "ou=Idmap"
end
@@ -297,9 +316,18 @@
:ssha
end
def normalize_password_hash_type(type)
type.to_s.downcase.to_sym
+ end
+
+ def samba4
+ smb_conf = self[:smb_conf]
+ if smb_conf and /^\s*server\s*role\s*=/ =~ File.read(smb_conf)
+ true
+ else
+ false
+ end
end
AVAILABLE_HASH_TYPES = [:crypt, :md5, :smd5, :sha, :ssha]
def validate_password_hash_type(type)
unless AVAILABLE_HASH_TYPES.include?(type)