source: n4d-ldap/trunk/fuentes/install/usr/share/n4d-ldap/one-shots/ldap-fix-netadmin @ 149

Last change on this file since 149 was 149, checked in by hectorgh, 4 years ago

adding project files

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/env python
2
3import xmlrpclib
4import ldap
5import grp
6import time
7import smbpasswd
8import sys
9
10def get_ldap_pass():
11
12        try:
13                f=open("/etc/lliurex-secrets/passgen/ldap.secret")
14                lines=f.readlines()
15                f.close()
16                password=lines[0].replace("\n","")
17                return password
18        except:
19                return None
20               
21
22
23def mod_ldap():
24       
25        c=xmlrpclib.ServerProxy("https://localhost:9779")
26        url=c.get_variable("","VariablesManager","CLIENT_LDAP_URI")
27        base_dn=c.get_variable("","VariablesManager","LDAP_BASE_DN")
28        path="uid=netadmin,ou=Admins,ou=People,dc=ma5,dc=lliurex,dc=net"
29        adm_path="cn=admin,"+base_dn   
30        password=get_ldap_pass()
31        ldp=ldap.initialize(url)
32        ldp.bind_s(adm_path,password)
33
34        mod_list=[]
35        mod=( ldap.MOD_REPLACE, "sambaNTPassword", smbpasswd.nthash(password))
36        mod_list.append(mod)
37        mod=( ldap.MOD_REPLACE, "sambaLMPassword", smbpasswd.lmhash(password))
38        mod_list.append(mod)
39        mod=( ldap.MOD_REPLACE, "sambaPwdLastSet", str(int(time.time())))
40        mod_list.append(mod)
41        mod=( ldap.MOD_REPLACE, "sambaAcctFlags", "[U]")
42        mod_list.append(mod)
43        sys.stdout.write("* Fixing netadmin...\t")
44        ldp.modify_s("uid=netadmin,ou=Admins,ou=People,dc=ma5,dc=lliurex,dc=net",mod_list)
45        sys.stdout.write("OK\n")
46       
47#def mod_ldap
48
49
50try:
51        mod_ldap()
52       
53except Exception as e:
54        pass
Note: See TracBrowser for help on using the repository browser.