6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/ldappasswd.rb', line 6
def self.ldap_passwd(host, bind_dn, current_pw, new_pw, user_dn)
started = Time.now
res = nil
Open3.popen3(
'ldappasswd',
'-x',
'-Z',
'-h', host,
'-D', bind_dn.to_s,
'-w', current_pw,
'-s', new_pw,
'-o', 'nettimeout=20',
user_dn.to_s
) do |stdin, stdout, stderr, wait_thr|
wait_thr.join
res = {
:duration => (Time.now.to_f - started.to_f).round(5),
:stdout => stdout.read(1024 * 5),
:stderr => stderr.read(1024 * 5),
:exit_status => wait_thr.value.exitstatus
}
end
return res
end
|