activesambaldap 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS.en +9 -0
- data/NEWS.ja +10 -0
- data/README.en +310 -0
- data/README.ja +307 -0
- data/Rakefile +95 -0
- data/bin/asl-groupadd +70 -0
- data/bin/asl-groupdel +58 -0
- data/bin/asl-groupmod +133 -0
- data/bin/asl-groupshow +31 -0
- data/bin/asl-passwd +99 -0
- data/bin/asl-populate +96 -0
- data/bin/asl-purge +24 -0
- data/bin/asl-samba-computeradd +94 -0
- data/bin/asl-samba-groupadd +55 -0
- data/bin/asl-samba-groupdel +53 -0
- data/bin/asl-samba-groupmod +98 -0
- data/bin/asl-samba-useradd +98 -0
- data/bin/asl-samba-userdel +47 -0
- data/bin/asl-samba-usermod +92 -0
- data/bin/asl-useradd +263 -0
- data/bin/asl-userdel +75 -0
- data/bin/asl-usermod +335 -0
- data/bin/asl-usershow +31 -0
- data/lib/active_samba_ldap/account.rb +199 -0
- data/lib/active_samba_ldap/base.rb +126 -0
- data/lib/active_samba_ldap/command.rb +94 -0
- data/lib/active_samba_ldap/computer.rb +13 -0
- data/lib/active_samba_ldap/computer_account.rb +34 -0
- data/lib/active_samba_ldap/configuration.rb +322 -0
- data/lib/active_samba_ldap/dc.rb +17 -0
- data/lib/active_samba_ldap/entry.rb +80 -0
- data/lib/active_samba_ldap/group.rb +182 -0
- data/lib/active_samba_ldap/idmap.rb +17 -0
- data/lib/active_samba_ldap/ou.rb +18 -0
- data/lib/active_samba_ldap/populate.rb +254 -0
- data/lib/active_samba_ldap/samba_account.rb +200 -0
- data/lib/active_samba_ldap/samba_computer.rb +20 -0
- data/lib/active_samba_ldap/samba_group.rb +126 -0
- data/lib/active_samba_ldap/samba_user.rb +39 -0
- data/lib/active_samba_ldap/unix_id_pool.rb +41 -0
- data/lib/active_samba_ldap/user.rb +14 -0
- data/lib/active_samba_ldap/user_account.rb +30 -0
- data/lib/active_samba_ldap/version.rb +3 -0
- data/lib/active_samba_ldap.rb +29 -0
- data/lib/samba/encrypt.rb +86 -0
- data/misc/rd2html.rb +42 -0
- data/rails/plugin/active_samba_ldap/README +30 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/scaffold_asl_generator.rb +28 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/computer.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/dc.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/group.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/idmap.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/ldap.yml +24 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/ou.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_controller.rb +12 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_helper.rb +2 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_index.rhtml +17 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_populate.rhtml +15 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/samba_purge.rhtml +10 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/unix_id_pool.rb +3 -0
- data/rails/plugin/active_samba_ldap/generators/scaffold_asl/templates/user.rb +3 -0
- data/rails/plugin/active_samba_ldap/init.rb +6 -0
- data/test/asl-test-utils.rb +276 -0
- data/test/command.rb +64 -0
- data/test/config.yaml.sample +17 -0
- data/test/run-test.rb +18 -0
- data/test/test-unit-ext/always-show-result.rb +28 -0
- data/test/test-unit-ext/priority.rb +159 -0
- data/test/test-unit-ext.rb +2 -0
- data/test/test_asl_groupadd.rb +69 -0
- data/test/test_asl_groupdel.rb +88 -0
- data/test/test_asl_groupmod.rb +256 -0
- data/test/test_asl_groupshow.rb +21 -0
- data/test/test_asl_passwd.rb +125 -0
- data/test/test_asl_populate.rb +92 -0
- data/test/test_asl_purge.rb +21 -0
- data/test/test_asl_useradd.rb +710 -0
- data/test/test_asl_userdel.rb +73 -0
- data/test/test_asl_usermod.rb +541 -0
- data/test/test_asl_usershow.rb +27 -0
- data/test/test_group.rb +21 -0
- data/test/test_password.rb +51 -0
- data/test/test_samba_encrypt.rb +36 -0
- data/test/test_user_home_directory.rb +43 -0
- metadata +177 -0
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'active_samba_ldap/group'
|
2
|
+
|
3
|
+
module ActiveSambaLdap
|
4
|
+
class SambaGroup < Group
|
5
|
+
include Reloadable::Subclasses
|
6
|
+
|
7
|
+
# from librpc/ndr/security.h in Samba
|
8
|
+
SID_BUILTIN = "S-1-5-32"
|
9
|
+
|
10
|
+
# from source/include/rpc_misc.c in Samba
|
11
|
+
DOMAIN_ADMINS_RID = 0x00000200
|
12
|
+
DOMAIN_USERS_RID = 0x00000201
|
13
|
+
DOMAIN_GUESTS_RID = 0x00000202
|
14
|
+
DOMAIN_COMPUTERS_RID = 0x00000203
|
15
|
+
|
16
|
+
LOCAL_ADMINS_RID = 0x00000220
|
17
|
+
LOCAL_USERS_RID = 0x00000221
|
18
|
+
LOCAL_GUESTS_RID = 0x00000222
|
19
|
+
LOCAL_POWER_USERS_RID = 0x00000223
|
20
|
+
|
21
|
+
LOCAL_ACCOUNT_OPERATORS_RID = 0x00000224
|
22
|
+
LOCAL_SYSTEM_OPERATORS_RID = 0x00000225
|
23
|
+
LOCAL_PRINT_OPERATORS_RID = 0x00000226
|
24
|
+
LOCAL_BACKUP_OPERATORS_RID = 0x00000227
|
25
|
+
|
26
|
+
LOCAL_REPLICATORS_RID = 0x00000228
|
27
|
+
|
28
|
+
|
29
|
+
# from source/rpc_server/srv_util.c in Samba
|
30
|
+
DOMAIN_ADMINS_NAME = "Domain Administrators"
|
31
|
+
DOMAIN_USERS_NAME = "Domain Users"
|
32
|
+
DOMAIN_GUESTS_NAME = "Domain Guests"
|
33
|
+
DOMAIN_COMPUTERS_NAME = "Domain Computers"
|
34
|
+
|
35
|
+
|
36
|
+
WELL_KNOWN_RIDS = []
|
37
|
+
WELL_KNOWN_NAMES = []
|
38
|
+
constants.each do |name|
|
39
|
+
case name
|
40
|
+
when /_RID$/
|
41
|
+
WELL_KNOWN_RIDS << const_get(name)
|
42
|
+
when /_NAME$/
|
43
|
+
WELL_KNOWN_NAMES << const_get(name)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
# from source/librpc/idl/lsa.idl in Samba
|
49
|
+
TYPES = {
|
50
|
+
"domain" => 2,
|
51
|
+
"local" => 4,
|
52
|
+
"builtin" => 5,
|
53
|
+
}
|
54
|
+
|
55
|
+
class << self
|
56
|
+
def gid2rid(gid)
|
57
|
+
gid = Integer(gid)
|
58
|
+
if WELL_KNOWN_RIDS.include?(gid)
|
59
|
+
gid
|
60
|
+
else
|
61
|
+
2 * gid + 1001
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def rid2gid(rid)
|
66
|
+
rid = Integer(rid)
|
67
|
+
if WELL_KNOWN_RIDS.include?(rid)
|
68
|
+
rid
|
69
|
+
else
|
70
|
+
(rid - 1001) / 2
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def start_rid
|
75
|
+
gid2rid(start_gid)
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
def default_classes
|
80
|
+
super + ["sambaGroupMapping"]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def fill_default_values(options={})
|
85
|
+
change_type(options[:group_type] || "domain") unless samba_group_type
|
86
|
+
self.display_name ||= options[:display_name] || cn
|
87
|
+
super
|
88
|
+
end
|
89
|
+
|
90
|
+
def change_gid_number(gid, allow_non_unique=false)
|
91
|
+
super
|
92
|
+
rid = self.class.gid2rid(gid_number.to_s)
|
93
|
+
change_sid(rid, allow_non_unique)
|
94
|
+
end
|
95
|
+
|
96
|
+
def change_gid_number_by_rid(rid, allow_non_unique=false)
|
97
|
+
change_gid_number(self.class.rid2gid(rid), allow_non_unique)
|
98
|
+
end
|
99
|
+
|
100
|
+
def change_sid(rid, allow_non_unique=false)
|
101
|
+
if (LOCAL_ADMINS_RID..LOCAL_REPLICATORS_RID).include?(rid.to_i)
|
102
|
+
sid = "#{SID_BUILTIN}-#{rid}"
|
103
|
+
else
|
104
|
+
sid = "#{self.class.configuration[:sid]}-#{rid}"
|
105
|
+
end
|
106
|
+
# check_unique_sid_number(sid) unless allow_non_unique
|
107
|
+
self.samba_sid = sid
|
108
|
+
end
|
109
|
+
|
110
|
+
def rid
|
111
|
+
Integer(samba_sid.split(/-/).last)
|
112
|
+
end
|
113
|
+
|
114
|
+
def change_type(type)
|
115
|
+
normalized_type = type.to_s.downcase
|
116
|
+
if TYPES.has_key?(normalized_type)
|
117
|
+
type = TYPES[normalized_type]
|
118
|
+
elsif TYPES.values.include?(type.to_i)
|
119
|
+
# pass
|
120
|
+
else
|
121
|
+
raise ArgumentError, "invalid type: #{type}"
|
122
|
+
end
|
123
|
+
self.samba_group_type = type.to_s
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'active_samba_ldap/entry'
|
2
|
+
require 'active_samba_ldap/account'
|
3
|
+
require 'active_samba_ldap/user_account'
|
4
|
+
require 'active_samba_ldap/samba_account'
|
5
|
+
|
6
|
+
module ActiveSambaLdap
|
7
|
+
class SambaUser < Base
|
8
|
+
include Reloadable::Subclasses
|
9
|
+
|
10
|
+
include Entry
|
11
|
+
|
12
|
+
include Account
|
13
|
+
include UserAccount
|
14
|
+
include SambaAccount
|
15
|
+
|
16
|
+
def fill_default_values(options={})
|
17
|
+
super
|
18
|
+
|
19
|
+
subst = Proc.new do |key|
|
20
|
+
value = options[key]
|
21
|
+
if value
|
22
|
+
substitute_template(value)
|
23
|
+
else
|
24
|
+
substituted_value(key)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
self.samba_home_path ||= subst[:user_home_unc]
|
29
|
+
self.samba_home_drive ||= subst[:user_home_drive].sub(/([^:])$/, "\\1:")
|
30
|
+
self.samba_profile_path ||= subst[:user_profile]
|
31
|
+
self.samba_logon_script ||= subst[:user_logon_script]
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def default_account_flags
|
36
|
+
"[UH]"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module ActiveSambaLdap
|
2
|
+
class UnixIdPool < Base
|
3
|
+
include Reloadable::Subclasses
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def ldap_mapping(options={})
|
7
|
+
default_options = {
|
8
|
+
:dn_attribute => "sambaDomainName",
|
9
|
+
:prefix => "",
|
10
|
+
:classes => ["top", "sambaDomain", "sambaUnixIdPool"],
|
11
|
+
}
|
12
|
+
options = default_options.merge(options)
|
13
|
+
super options
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_available_uid_number(account_class)
|
18
|
+
find_available_number(account_class, "uidNumber", uid_number) do
|
19
|
+
account_class.configuration[:start_uid]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def find_available_gid_number(group_class)
|
24
|
+
find_available_number(group_class, "gidNumber", gid_number) do
|
25
|
+
group_class.configuration[:start_gid]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def find_available_number(klass, key, start_value)
|
31
|
+
number = Integer(start_value || yield)
|
32
|
+
|
33
|
+
100.times do |i|
|
34
|
+
return number if klass.search(:filter => "(#{key}=#{number})").empty?
|
35
|
+
number += 1
|
36
|
+
end
|
37
|
+
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'active_samba_ldap/entry'
|
2
|
+
require 'active_samba_ldap/account'
|
3
|
+
require 'active_samba_ldap/user_account'
|
4
|
+
|
5
|
+
module ActiveSambaLdap
|
6
|
+
class User < Base
|
7
|
+
include Reloadable::Subclasses
|
8
|
+
|
9
|
+
include Entry
|
10
|
+
|
11
|
+
include Account
|
12
|
+
include UserAccount
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ActiveSambaLdap
|
2
|
+
module UserAccount
|
3
|
+
NAME_RE = /\A#{Account::NAME_RE_SRC}\z/
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
super
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
base.validates_format_of :uid, :with => NAME_RE
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def valid_name?(name)
|
13
|
+
NAME_RE =~ name ? true : false
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def default_prefix
|
18
|
+
configuration[:users_suffix]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove_from_group(group)
|
23
|
+
group.users.delete(self)
|
24
|
+
end
|
25
|
+
|
26
|
+
def default_gid_number
|
27
|
+
self.class.configuration[:default_user_gid]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_gem_if_need = Proc.new do |library_name, gem_name, *options|
|
2
|
+
begin
|
3
|
+
require library_name
|
4
|
+
rescue LoadError
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem gem_name, *options
|
7
|
+
require library_name
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require_gem_if_need.call("active_ldap", "activeldap", ">= 0.8.0")
|
12
|
+
|
13
|
+
require 'active_samba_ldap/version'
|
14
|
+
require 'active_samba_ldap/base'
|
15
|
+
require "active_samba_ldap/configuration"
|
16
|
+
require 'active_samba_ldap/populate'
|
17
|
+
|
18
|
+
ActiveSambaLdap::Base.class_eval do
|
19
|
+
include ActiveSambaLdap::Configuration
|
20
|
+
include ActiveSambaLdap::Populate
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'active_samba_ldap/user'
|
24
|
+
require 'active_samba_ldap/group'
|
25
|
+
require 'active_samba_ldap/computer'
|
26
|
+
require 'active_samba_ldap/idmap'
|
27
|
+
require 'active_samba_ldap/unix_id_pool'
|
28
|
+
require 'active_samba_ldap/ou'
|
29
|
+
require 'active_samba_ldap/dc'
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
|
3
|
+
module Samba
|
4
|
+
module Encrypt
|
5
|
+
module_function
|
6
|
+
def lm_hash(password, encoding=nil)
|
7
|
+
dos_password = Private.convert_encoding("ISO-8859-1",
|
8
|
+
encoding || "UTF-8",
|
9
|
+
password.upcase)
|
10
|
+
if dos_password.size > 14
|
11
|
+
warn("password is truncated to 14 characters")
|
12
|
+
dos_password = dos_password[0, 14]
|
13
|
+
end
|
14
|
+
Private.encrypt_14characters(dos_password).unpack("C*").collect do |char|
|
15
|
+
"%02X" % char
|
16
|
+
end.join
|
17
|
+
end
|
18
|
+
|
19
|
+
def ntlm_hash(password, encoding=nil)
|
20
|
+
ucs2_password = Private.convert_encoding("UCS-2",
|
21
|
+
encoding || "UTF-8",
|
22
|
+
password)
|
23
|
+
if ucs2_password.size > 256
|
24
|
+
raise ArgumentError.new("must be <= 256 characters in UCS-2")
|
25
|
+
end
|
26
|
+
hex = OpenSSL::Digest::MD4.new(ucs2_password).hexdigest.upcase
|
27
|
+
hex
|
28
|
+
end
|
29
|
+
|
30
|
+
module Private
|
31
|
+
module_function
|
32
|
+
def convert_encoding(to, from, str)
|
33
|
+
if same_encoding?(to, from)
|
34
|
+
str
|
35
|
+
else
|
36
|
+
require 'iconv'
|
37
|
+
Iconv.iconv(to, from, str).join
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def normalize_encoding(encoding)
|
42
|
+
encoding.downcase.gsub(/-/, "_")
|
43
|
+
end
|
44
|
+
|
45
|
+
def same_encoding?(a, b)
|
46
|
+
na = normalize_encoding(a)
|
47
|
+
nb = normalize_encoding(b)
|
48
|
+
na == nb or na.gsub(/_/, '') == nb.gsub(/_/, '')
|
49
|
+
end
|
50
|
+
|
51
|
+
def str_to_key(str)
|
52
|
+
key = "\000" * 8
|
53
|
+
key[0] = str[0] >> 1;
|
54
|
+
key[1] = ((str[0] & 0x01) << 6) | (str[1] >> 2);
|
55
|
+
key[2] = ((str[1] & 0x03) << 5) | (str[2] >> 3);
|
56
|
+
key[3] = ((str[2] & 0x07) << 4) | (str[3] >> 4);
|
57
|
+
key[4] = ((str[3] & 0x0F) << 3) | (str[4] >> 5);
|
58
|
+
key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6);
|
59
|
+
key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7);
|
60
|
+
key[7] = str[6] & 0x7F;
|
61
|
+
|
62
|
+
key.size.times do |i|
|
63
|
+
key[i] = (key[i] << 1);
|
64
|
+
end
|
65
|
+
|
66
|
+
key
|
67
|
+
end
|
68
|
+
|
69
|
+
def des_crypt56(input, key_str, forward_only)
|
70
|
+
key = str_to_key(key_str)
|
71
|
+
encoder = OpenSSL::Cipher::DES.new
|
72
|
+
encoder.encrypt
|
73
|
+
encoder.key = key
|
74
|
+
encoder.update(input)
|
75
|
+
end
|
76
|
+
|
77
|
+
LM_MAGIC = "KGS!@\#$%"
|
78
|
+
def encrypt_14characters(chars)
|
79
|
+
raise ArgumentError.new("must be <= 14 characters") if chars.size > 14
|
80
|
+
chars = chars.to_s.ljust(14, "\000")
|
81
|
+
des_crypt56(LM_MAGIC, chars[0, 7], true) +
|
82
|
+
des_crypt56(LM_MAGIC, chars[7, 7], true)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/misc/rd2html.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
top = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
4
|
+
html_dir = File.join(top, "html")
|
5
|
+
|
6
|
+
require "fileutils"
|
7
|
+
|
8
|
+
css = "base.css"
|
9
|
+
kcode = "utf8"
|
10
|
+
|
11
|
+
options = [
|
12
|
+
"-I#{File.join(top, 'misc')}",
|
13
|
+
"-S",
|
14
|
+
"rd2",
|
15
|
+
"-rrd/rd2html-lib",
|
16
|
+
"--out-code=#{kcode}",
|
17
|
+
proc do |f|
|
18
|
+
"--html-title=#{File.basename(f)}"
|
19
|
+
end,
|
20
|
+
# proc do |f|
|
21
|
+
# "--with-css=#{css}"
|
22
|
+
# end,
|
23
|
+
proc do |f|
|
24
|
+
f
|
25
|
+
end
|
26
|
+
]
|
27
|
+
|
28
|
+
Dir[File.join(top, "*.{ja,en}")].each do |f|
|
29
|
+
if /(README|NEWS)\.(ja|en)\z/ =~ f
|
30
|
+
args = options.collect do |x|
|
31
|
+
if x.respond_to?(:call)
|
32
|
+
x.call(f)
|
33
|
+
else
|
34
|
+
x
|
35
|
+
end
|
36
|
+
end
|
37
|
+
output_base = File.basename(f).sub(/(ja|en)\z/, "html.\\1")
|
38
|
+
File.open(File.join(html_dir, output_base), "w") do |out|
|
39
|
+
out.puts(`ruby #{args.flatten.join(' ')}`)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
= ActiveSambaLdap plugin for Ruby on Rails
|
2
|
+
|
3
|
+
== Setup
|
4
|
+
|
5
|
+
You need to write RAILS_ROOT/config/ldap.yml like the following:
|
6
|
+
|
7
|
+
development:
|
8
|
+
host: 127.0.0.1
|
9
|
+
port: 389
|
10
|
+
base: dc=devel,dc=local,dc=net
|
11
|
+
bind_dn: cn=admin,dc=local,dc=net
|
12
|
+
password: secret
|
13
|
+
sid: S-1-5-21-915876905-2926214379-2876160357
|
14
|
+
|
15
|
+
test:
|
16
|
+
host: 127.0.0.1
|
17
|
+
port: 389
|
18
|
+
base: dc=test,dc=local,dc=net
|
19
|
+
bind_dn: cn=admin,dc=local,dc=net
|
20
|
+
password: secret
|
21
|
+
sid: S-1-5-21-915876905-2926214379-2876160357
|
22
|
+
|
23
|
+
production:
|
24
|
+
host: 127.0.0.1
|
25
|
+
port: 389
|
26
|
+
method: :tls
|
27
|
+
base: dc=production,dc=local,dc=net
|
28
|
+
bind_dn: cn=admin,dc=local,dc=net
|
29
|
+
password: secret
|
30
|
+
sid: S-1-5-21-915876905-2926214379-2876160357
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class ScaffoldAslGenerator < Rails::Generator::Base
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
|
5
|
+
m.template("ldap.yml", File.join("config", "ldap.yml"))
|
6
|
+
|
7
|
+
%w(user computer group unix_id_pool idmap ou dc).each do |component|
|
8
|
+
m.template("#{component}.rb",
|
9
|
+
File.join("app", "models", "#{component}.rb"))
|
10
|
+
end
|
11
|
+
|
12
|
+
component = "samba"
|
13
|
+
controller_class_name = "#{Inflector.camelize(component)}Controller"
|
14
|
+
options = {:assigns => {:controller_class_name => controller_class_name}}
|
15
|
+
|
16
|
+
m.template("#{component}_controller.rb",
|
17
|
+
File.join("app", "controllers", "#{component}_controller.rb"))
|
18
|
+
m.template("#{component}_helper.rb",
|
19
|
+
File.join("app", "helpers", "#{component}_helper.rb"))
|
20
|
+
m.directory(File.join("app", "views", component))
|
21
|
+
%w(index populate purge).each do |action|
|
22
|
+
m.template("#{component}_#{action}.rhtml",
|
23
|
+
File.join("app", "views", component, "#{action}.rhtml"),
|
24
|
+
options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
development:
|
2
|
+
host: 127.0.0.1
|
3
|
+
port: 389
|
4
|
+
base: dc=devel,dc=local,dc=net
|
5
|
+
bind_dn: cn=admin,dc=local,dc=net
|
6
|
+
password: secret
|
7
|
+
sid: S-1-5-21-915876905-2926214379-2876160357
|
8
|
+
|
9
|
+
test:
|
10
|
+
host: 127.0.0.1
|
11
|
+
port: 389
|
12
|
+
base: dc=test,dc=local,dc=net
|
13
|
+
bind_dn: cn=admin,dc=local,dc=net
|
14
|
+
password: secret
|
15
|
+
sid: S-1-5-21-915876905-2926214379-2876160357
|
16
|
+
|
17
|
+
production:
|
18
|
+
host: 127.0.0.1
|
19
|
+
port: 389
|
20
|
+
method: :tls
|
21
|
+
base: dc=production,dc=local,dc=net
|
22
|
+
bind_dn: cn=admin,dc=local,dc=net
|
23
|
+
password: secret
|
24
|
+
sid: S-1-5-21-915876905-2926214379-2876160357
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title><%= controller_class_name %>: <%%= controller.action_name %></title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
<h1>Samba + LDAP Management</h1>
|
7
|
+
<ul>
|
8
|
+
<li>
|
9
|
+
<%%= link_to "Populate Samba + LDAP environment",
|
10
|
+
:action => :populate %>
|
11
|
+
</li>
|
12
|
+
<li>
|
13
|
+
<%%= link_to "Purge Samba + LDAP environment", :action => :purge %>
|
14
|
+
</li>
|
15
|
+
</ul>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title><%= controller_class_name %>: <%%= controller.action_name %></title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
<h1>Samba + LDAP Management</h1>
|
7
|
+
<p>Populated.</p>
|
8
|
+
<ul>
|
9
|
+
<%% @entries.each do |entry| %>
|
10
|
+
<li><%%= h entry.dn %></li>
|
11
|
+
<%% end %>
|
12
|
+
</ul>
|
13
|
+
<%%= link_to "Back", :action => nil %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
require_dependency 'active_samba_ldap'
|
2
|
+
ActiveSambaLdap::Base.logger ||= RAILS_DEFAULT_LOGGER
|
3
|
+
ldap_configuration_file = File.join(RAILS_ROOT, 'config', 'ldap.yml')
|
4
|
+
ActiveSambaLdap::Base.configurations =
|
5
|
+
ActiveSambaLdap::Configuration.read(ldap_configuration_file)
|
6
|
+
ActiveSambaLdap::Base.establish_connection
|