Tâche #31373
Scénario #30983: Implementer la migration par la sauvegarde/restauration en 2.8.1 (amonecole)
Extraire les comptes pendant la sauvegarde
Start date:
11/09/2020
Due date:
% Done:
100%
Remaining (hours):
0.0
Associated revisions
extraction de l'annuaire sur amonecole 26 (ref #31373)
extraction de l'annuaire sur amonecole 26 (ref #31373)
History
#1 Updated by Emmanuel GARETTE almost 3 years ago
- Status changed from Nouveau to En cours
#2 Updated by Emmanuel GARETTE almost 3 years ago
Script d'extraction :
#!/usr/bin/python import ldap import csv from creole.client import CreoleClient from creole.eosfunc import pwdreader from scribe.ldapconf import GROUP_FILTER, SHARE_FILTER, USER_FILTER, RACINE client = CreoleClient() host = 'ldap://{}:389'.format(client.get_creole('container_ip_annuaire')) ldap_reader="cn=reader,o=gouv,c=fr" ldap_reader_passfile="/root/.reader" dn = client.get_creole('ldap_reader') pw = pwdreader("", client.get_creole('ldap_reader_passfile')) base_dn = client.get_creole('ldap_base_dn') con = ldap.initialize(host) con.simple_bind_s(dn, pw) # le DN change en 2.8 len_racine = len(RACINE) + 1 def extract(filter_, filename): # Extract groups res = con.search_s(base_dn, ldap.SCOPE_SUBTREE, "(&{})".format(filter_)) with open(filename, 'w') as csvfile: headers = {'dn'} for obj_dn, obj in res: headers |= set(obj.keys()) writer = csv.DictWriter(csvfile, fieldnames=list(headers)) writer.writeheader() for obj_dn, obj in res: export_obj = {'dn': obj_dn[:-len_racine]} for key, value in obj.items(): if not isinstance(value, list): raise Exception('hu?') if len(value) == 0: raise Exception('hu?') if len(value) == 1: value = value[0] export_obj[key] = value writer.writerow(export_obj) extract(GROUP_FILTER, 'groups.csv') extract(SHARE_FILTER, 'shares.csv') extract(USER_FILTER, 'users.csv') con.unbind()
#3 Updated by Emmanuel GARETTE almost 3 years ago
- Assigned To set to Emmanuel GARETTE
#4 Updated by Emmanuel GARETTE almost 3 years ago
- Status changed from En cours to Résolu
#5 Updated by Joël Cuissinat over 2 years ago
- Status changed from Résolu to Fermé
- % Done changed from 0 to 100
- Remaining (hours) set to 0.0
Nouvelle étape :
* Extraction de l'annuaire au format CSV
Après exécution :
root@amonecole:~/svg/scribe-00000003# ls csv/ groups.csv shares.csv users.csv
root@amonecole:~/svg/scribe-00000003# head -n3 csv/users.csv cn,objectClass,sambaAcctFlags,ENTEleveMajeur,sambaLogoffTime,sambaPwdCanChange,dateNaissance,ENTEleveMEF,userPassword,radiusTunnelType,sambaLogonTime,mail,dn,ENTEleveNivFormation,radiusFilterId,gidNumber,employeeNumber,sambaKickoffTime,ENTPersonDateNaissance,sambaPwdLastSet,sambaNTPassword,mailDir,Divcod,ENTEleveLibelleMEF,mailHost,gecos,Meflcf,homeDirectory,Ine,givenName,ENTEleveFiliere,uid,sambaProfilePath,ENTEleveEnseignements,radiusTunnelMediumType,uidNumber,ENTEleveStructRattachId,sambaPrimaryGroupSID,shadowLastChange,ENTPersonProfils,sambaHomePath,ENTPersonSexe,ENTPersonJointure,sambaPwdMustChange,sambaLMPassword,ENTEleveStatutEleve,loginShell,ENTPersonLogin,intid,LastUpdate,displayName,sambaHomeDrive,typeadmin,ENTEleveClasses,personalTitle,ENTPersonNomPatro,sambaSID,sn,codecivilite admin admin,"['top', 'person', 'organizationalPerson', 'posixAccount', 'shadowAccount', 'inetOrgPerson', 'sambaSamAccount', 'administrateur', 'ENTPerson', 'ENTAuxEnseignant', 'radiusprofile']",[U],,2147483647,0,00000101,,{SSHA}JKEPngISCQ+dLtHuhmMWln43iu5oREVE,VLAN,0,admin@etb3.ac-test.fr,"uid=admin,ou=local,ou=personnels,ou=utilisateurs,ou=00000003",,Enterasys:version=1:policy=Enterprise User,10001,,2147483647,00000101,1610155623,873AB87F6889C41A3DB5C45D830005EB,/home/mail/admin/,,,localhost,admin admin,,/home/a/admin,,admin,,admin,,,IEEE-802,10004,,S-1-5-21-3271737298-1577670591-792995317-21003,18636,enseignant,\\scribe\admin\perso,M,ENT,1610155623,DE7D34351719C70FAAD3B435B51404EE,,/bin/false,admin,,20210109,admin admin,U:,1,,M.,admin,S-1-5-21-3271737298-1577670591-792995317-21008,admin,1 6a 01,"['top', 'person', 'organizationalPerson', 'posixAccount', 'shadowAccount', 'inetOrgPerson', 'sambaSamAccount', 'Eleves', 'ENTPerson', 'ENTEleve', 'radiusprofile']",[U],-,2147483647,0,20000101,n6,{SSHA}WYrc9iytGNJzS7Sq9BgRQCyk67xoYlRk,VLAN,0,6a.01@i-etb3.ac-test.fr,"uid=6a.01,ou=local,ou=eleves,ou=utilisateurs,ou=00000003",-,Enterasys:version=1:policy=Enterprise User,10002,1,2147483647,20000101,0,CAD1126270FCCF463ACF56CCFB96A9A8,/home/mail/6a.01/,6a,n6,localhost,6a 01,n6,/home/6/6a.01,,6a,-,6a.01,\\scribe\netlogon\profil,-,IEEE-802,10005,,S-1-5-21-3271737298-1577670591-792995317-21005,18636,eleve,\\scribe\6a.01\perso,M,ENT,1610174561,CF531B5643708B0741427A8C7F706E41,ELEVE,/bin/false,6a.01,,20210109,6a 01,U:,,"ou=00000003,ou=ac-test,ou=education,o=gouv,c=fr$6a",M.,01,S-1-5-21-3271737298-1577670591-792995317-21010,01,1