ソースを参照

First implementation of LDAP sync

Andrea Fazzi 5 年 前
コミット
aeda50351a

+ 23 - 1
compose/karmen/docker-compose.yml

@@ -19,7 +19,29 @@ services:
       - ./sql:/docker-entrypoint-initdb.d
     env_file:
       - db.env
-      
+
+  ldap_server:
+    restart: always
+    build: ./ldap
+    command: --loglevel debug
+    domainname: foo.org
+    hostname: foo.org
+    ports:
+      - 389:389
+    environment:
+      - LDAP_ORGANISATION=Foo Organization
+      - LDAP_DOMAIN=foo.org
+      - LDAP_ADMIN_PASSWORD=admin
+
+  ldap_web_client:
+    restart: always
+    image: osixia/phpldapadmin
+    environment:
+      - PHPLDAPADMIN_LDAP_HOSTS=ldap_server
+      - PHPLDAPADMIN_HTTPS=false
+    ports:
+      - 3001:80
+
 volumes:
   db:
   

+ 0 - 464
compose/karmen/karmen_test.sql

@@ -1,464 +0,0 @@
--- MySQL dump 10.16  Distrib 10.3.9-MariaDB, for debian-linux-gnu (x86_64)
---
--- Host: localhost    Database: karmen_dev
--- ------------------------------------------------------
--- Server version	10.3.9-MariaDB-1:10.3.9+maria~bionic
-
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
-/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
-/*!40103 SET TIME_ZONE='+00:00' */;
-/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
-/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
-/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-
---
--- Table structure for table `activities`
---
-
-DROP TABLE IF EXISTS `activities`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `activities` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `class_id` int(10) unsigned DEFAULT NULL,
-  `teacher_id` int(10) unsigned DEFAULT NULL,
-  `subject_id` int(10) unsigned DEFAULT NULL,
-  `hours` int(11) DEFAULT NULL,
-  `student_id` int(10) unsigned DEFAULT NULL,
-  `supply_teacher_id` int(10) unsigned DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_activities_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `activities`
---
-
-LOCK TABLES `activities` WRITE;
-/*!40000 ALTER TABLE `activities` DISABLE KEYS */;
-INSERT INTO `activities` VALUES (1,'2018-08-24 17:17:22','2018-08-24 17:17:22',NULL,'1 A MATEMATICA 2h',1,1,1,2,NULL,NULL),(2,'2018-08-24 17:18:01','2018-08-24 17:18:01',NULL,'1 A INGLESE 2h',1,2,3,2,NULL,NULL),(3,'2018-08-24 17:18:26','2018-08-24 17:18:26',NULL,'1 A ITALIANO 5h',1,3,2,5,NULL,NULL),(4,'2018-08-24 17:23:58','2018-08-24 17:23:58',NULL,'1 A STORIA DELL\'ARTE 2h',1,5,4,2,NULL,NULL),(5,'2018-08-24 17:24:20','2018-08-24 17:24:20',NULL,'1 A TECNOLOGIA 2h',1,4,9,2,NULL,NULL),(6,'2018-08-24 17:24:41','2018-08-24 17:24:41',NULL,'1 A FRANCESE 2h',1,7,7,2,NULL,NULL),(7,'2018-08-24 17:25:13','2018-08-24 17:25:13',NULL,'1 A RELIGIONE 2h',1,9,6,2,NULL,NULL),(8,'2018-08-24 17:25:44','2018-08-24 17:25:44',NULL,'1 A STORIA 2h',1,6,8,2,NULL,NULL),(9,'2018-08-24 17:26:15','2018-08-24 17:26:15',NULL,'1 A SCIENZE 2h',1,8,5,2,NULL,NULL),(10,'2018-09-18 09:21:28','2018-09-18 09:21:28',NULL,NULL,1,10,10,5,1,NULL),(11,'2018-09-18 09:27:33','2018-09-18 09:27:33',NULL,NULL,1,11,10,5,1,NULL),(12,'2018-09-18 09:29:43','2018-09-18 09:29:43',NULL,NULL,1,11,10,3,2,NULL),(13,'2018-10-12 11:20:39','2018-10-16 09:37:23',NULL,NULL,3,1,5,2,0,2);
-/*!40000 ALTER TABLE `activities` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `administratives`
---
-
-DROP TABLE IF EXISTS `administratives`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `administratives` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `surname` varchar(255) DEFAULT NULL,
-  `username` varchar(255) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `email` varchar(255) DEFAULT NULL,
-  `telephone_number` varchar(255) DEFAULT NULL,
-  `role` int(11) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_administratives_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `administratives`
---
-
-LOCK TABLES `administratives` WRITE;
-/*!40000 ALTER TABLE `administratives` DISABLE KEYS */;
-/*!40000 ALTER TABLE `administratives` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `classes`
---
-
-DROP TABLE IF EXISTS `classes`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `classes` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `coordinator_id` int(10) unsigned DEFAULT NULL,
-  `minuter_id` int(10) unsigned DEFAULT NULL,
-  `alias` varchar(255) DEFAULT NULL,
-  `year` int(11) DEFAULT NULL,
-  `section` varchar(255) DEFAULT NULL,
-  `field` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_classes_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `classes`
---
-
-LOCK TABLES `classes` WRITE;
-/*!40000 ALTER TABLE `classes` DISABLE KEYS */;
-INSERT INTO `classes` VALUES (1,'2018-08-24 17:11:29','2018-08-24 17:26:35',NULL,'1 A',3,2,NULL,NULL,NULL,NULL),(2,'2018-08-24 17:12:43','2018-08-24 17:12:43','2018-08-24 17:17:01','1 A',1,2,NULL,NULL,NULL,NULL),(3,'2018-10-12 11:20:21','2018-10-12 11:20:21',NULL,'1 B',0,0,'',1,'B','SCIENZE UMANE');
-/*!40000 ALTER TABLE `classes` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `department_teachers`
---
-
-DROP TABLE IF EXISTS `department_teachers`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `department_teachers` (
-  `department_id` int(10) unsigned NOT NULL,
-  `teacher_id` int(10) unsigned NOT NULL,
-  PRIMARY KEY (`department_id`,`teacher_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `department_teachers`
---
-
-LOCK TABLES `department_teachers` WRITE;
-/*!40000 ALTER TABLE `department_teachers` DISABLE KEYS */;
-/*!40000 ALTER TABLE `department_teachers` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `departments`
---
-
-DROP TABLE IF EXISTS `departments`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `departments` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `coordinator_id` int(10) unsigned DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_departments_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `departments`
---
-
-LOCK TABLES `departments` WRITE;
-/*!40000 ALTER TABLE `departments` DISABLE KEYS */;
-INSERT INTO `departments` VALUES (1,'2018-09-13 16:21:31','2018-09-13 16:30:10',NULL,'LINGUE STRANIERE',NULL),(4,'2018-09-18 09:20:14','2018-09-18 09:20:14',NULL,'SOSTEGNO',0);
-/*!40000 ALTER TABLE `departments` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `directors`
---
-
-DROP TABLE IF EXISTS `directors`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `directors` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `surname` varchar(255) DEFAULT NULL,
-  `username` varchar(255) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `email` varchar(255) DEFAULT NULL,
-  `telephone_number` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_directors_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `directors`
---
-
-LOCK TABLES `directors` WRITE;
-/*!40000 ALTER TABLE `directors` DISABLE KEYS */;
-/*!40000 ALTER TABLE `directors` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `issues`
---
-
-DROP TABLE IF EXISTS `issues`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `issues` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `description` varchar(255) DEFAULT NULL,
-  `type` int(10) unsigned DEFAULT NULL,
-  `reported` tinyint(1) DEFAULT NULL,
-  `teacher_id` int(10) unsigned DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_issues_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `issues`
---
-
-LOCK TABLES `issues` WRITE;
-/*!40000 ALTER TABLE `issues` DISABLE KEYS */;
-/*!40000 ALTER TABLE `issues` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `schools`
---
-
-DROP TABLE IF EXISTS `schools`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `schools` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `address` varchar(255) DEFAULT NULL,
-  `domain` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_schools_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `schools`
---
-
-LOCK TABLES `schools` WRITE;
-/*!40000 ALTER TABLE `schools` DISABLE KEYS */;
-INSERT INTO `schools` VALUES (1,'2018-08-24 17:19:56','2018-08-24 17:19:56',NULL,'Scuola media inferiore \"Leonardo da Vinci\"','via Castroneria 4, Perlizzi (TN)','scuolamediadavinci.gov.it');
-/*!40000 ALTER TABLE `schools` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `students`
---
-
-DROP TABLE IF EXISTS `students`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `students` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `surname` varchar(255) DEFAULT NULL,
-  `username` varchar(255) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `email` varchar(255) DEFAULT NULL,
-  `telephone_number` varchar(255) DEFAULT NULL,
-  `plain_password` varchar(255) DEFAULT NULL,
-  `class_id` int(10) unsigned DEFAULT NULL,
-  `alt_email` varchar(255) DEFAULT NULL,
-  `date_from` timestamp NULL DEFAULT NULL,
-  `date_to` timestamp NULL DEFAULT NULL,
-  `regenerate` tinyint(1) DEFAULT 0,
-  `handicap` tinyint(1) DEFAULT NULL,
-  `dsa` tinyint(1) DEFAULT NULL,
-  `bes` tinyint(1) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_students_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `students`
---
-
-LOCK TABLES `students` WRITE;
-/*!40000 ALTER TABLE `students` DISABLE KEYS */;
-INSERT INTO `students` VALUES (1,'2018-09-18 09:12:14','2018-09-18 09:41:15',NULL,'Mario','ROSSI','','','','','',1,NULL,NULL,NULL,0,NULL,NULL,NULL),(2,'2018-09-18 09:29:07','2018-09-18 09:40:41',NULL,'Francesco','CONTINO','','','','','',1,NULL,NULL,NULL,0,NULL,NULL,NULL);
-/*!40000 ALTER TABLE `students` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `subjects`
---
-
-DROP TABLE IF EXISTS `subjects`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `subjects` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `department_id` int(10) unsigned DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_subjects_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `subjects`
---
-
-LOCK TABLES `subjects` WRITE;
-/*!40000 ALTER TABLE `subjects` DISABLE KEYS */;
-INSERT INTO `subjects` VALUES (1,'2018-08-24 17:09:21','2018-08-24 17:09:21',NULL,'MATEMATICA',0),(2,'2018-08-24 17:09:35','2018-08-24 17:09:35',NULL,'ITALIANO',0),(3,'2018-08-24 17:09:44','2018-08-24 17:09:44',NULL,'INGLESE',0),(4,'2018-08-24 17:21:29','2018-08-24 17:21:29',NULL,'STORIA DELL\'ARTE',0),(5,'2018-08-24 17:21:44','2018-08-24 17:21:44',NULL,'SCIENZE',0),(6,'2018-08-24 17:21:59','2018-08-24 17:21:59',NULL,'RELIGIONE',0),(7,'2018-08-24 17:22:31','2018-09-13 16:52:35',NULL,'FRANCESE',1),(8,'2018-08-24 17:23:19','2018-08-24 17:23:19',NULL,'STORIA',0),(9,'2018-08-24 17:23:33','2018-08-24 17:23:33',NULL,'TECNOLOGIA',0),(10,'2018-09-18 09:20:52','2018-09-18 09:20:52',NULL,'SOSTEGNO',4);
-/*!40000 ALTER TABLE `subjects` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `teacher_classes`
---
-
-DROP TABLE IF EXISTS `teacher_classes`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `teacher_classes` (
-  `teacher_id` int(10) unsigned NOT NULL,
-  `class_id` int(10) unsigned NOT NULL,
-  PRIMARY KEY (`teacher_id`,`class_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `teacher_classes`
---
-
-LOCK TABLES `teacher_classes` WRITE;
-/*!40000 ALTER TABLE `teacher_classes` DISABLE KEYS */;
-INSERT INTO `teacher_classes` VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1);
-/*!40000 ALTER TABLE `teacher_classes` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `teacher_subjects`
---
-
-DROP TABLE IF EXISTS `teacher_subjects`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `teacher_subjects` (
-  `subject_id` int(10) unsigned NOT NULL,
-  `teacher_id` int(10) unsigned NOT NULL,
-  PRIMARY KEY (`subject_id`,`teacher_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `teacher_subjects`
---
-
-LOCK TABLES `teacher_subjects` WRITE;
-/*!40000 ALTER TABLE `teacher_subjects` DISABLE KEYS */;
-INSERT INTO `teacher_subjects` VALUES (1,1),(2,3),(3,2),(4,5),(5,8),(6,9),(7,7),(8,6),(9,4);
-/*!40000 ALTER TABLE `teacher_subjects` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `teachers`
---
-
-DROP TABLE IF EXISTS `teachers`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `teachers` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `surname` varchar(255) DEFAULT NULL,
-  `username` varchar(255) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `email` varchar(255) DEFAULT NULL,
-  `telephone_number` varchar(255) DEFAULT NULL,
-  `hours` int(11) DEFAULT NULL,
-  `curr_hours` int(11) DEFAULT NULL,
-  `the_boss_id` int(10) unsigned DEFAULT NULL,
-  `plain_password` varchar(255) DEFAULT NULL,
-  `alt_email` varchar(255) DEFAULT NULL,
-  `date_from` timestamp NULL DEFAULT NULL,
-  `date_to` timestamp NULL DEFAULT NULL,
-  `regenerate` tinyint(1) DEFAULT 0,
-  PRIMARY KEY (`id`),
-  KEY `idx_teachers_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `teachers`
---
-
-LOCK TABLES `teachers` WRITE;
-/*!40000 ALTER TABLE `teachers` DISABLE KEYS */;
-INSERT INTO `teachers` VALUES (1,'2018-08-24 17:06:38','2018-08-24 17:17:22',NULL,'Amilcare','AGOSTINO','amilcare.agostino','TpbbDZmSdjzOzEcm5797h2TXY/hzYWx0','amilcare.agostino@foo.org','',18,2,0,NULL,NULL,NULL,NULL,0),(2,'2018-08-24 17:06:58','2018-08-24 17:18:01',NULL,'Assuntina','DONADONI','assuntina.donadoni','Fi28Y8Q76pqz3ggoAuXvMNliew9zYWx0','assuntina.donadoni@foo.org','',18,2,0,NULL,NULL,NULL,NULL,0),(3,'2018-08-24 17:07:14','2018-08-24 17:18:26',NULL,'Costanza','LUNGA','costanza.lunga','//XInIkvIeMYj0+x9AsabCyA8zVzYWx0','costanza.lunga@foo.org','',18,5,0,NULL,NULL,NULL,NULL,0),(4,'2018-08-24 17:07:28','2018-08-24 17:24:20',NULL,'Giacomo','DEL BEN','giacomo.delben','TTdp/vYL+NjgJZTErlceSVwCa1lzYWx0','giacomo.delben@foo.org','',18,2,0,NULL,NULL,NULL,NULL,0),(5,'2018-08-24 17:07:51','2018-08-24 17:23:58',NULL,'Giorgio','ARISTI','giorgio.aristi','bbtj5tK+TSBKd38G/zHK6TUo0JZzYWx0','giorgio.aristi@foo.org','',18,2,0,NULL,NULL,NULL,NULL,0),(6,'2018-08-24 17:08:12','2018-08-24 17:25:44',NULL,'Vittoria','GIRONI','vittoria.gironi','jS5M30Y9d5JUsyXSfxU1Vz4Tmc1zYWx0','vittoria.gironi@foo.org','',18,2,0,NULL,NULL,NULL,NULL,0),(7,'2018-08-24 17:08:33','2018-08-24 17:24:41',NULL,'Francesco','DELLE ROSE','francesco.dellerose','9HakZF2Oh1vZy+8J/doqR1Jpr/lzYWx0','francesco.dellerose@foo.org','',18,2,0,NULL,NULL,NULL,NULL,0),(8,'2018-08-24 17:08:51','2018-08-24 17:26:15',NULL,'Andrea','PETRUZZELLI','andrea.petruzzelli','enbmvOYnUs/2IkttlR90h3oJC9dzYWx0','andrea.petruzzelli@foo.org','',18,2,0,NULL,NULL,NULL,NULL,0),(9,'2018-08-24 17:09:07','2018-08-24 17:25:13',NULL,'Piero','FRANCESCHINI','piero.franceschini','eGAGAG9etZ+rehwW0A/KRWt/7CFzYWx0','piero.franceschini@foo.org','',18,2,0,NULL,NULL,NULL,NULL,0),(10,'2018-09-18 09:20:32','2018-09-18 09:20:32',NULL,'Pierpaolo','ULCINO','','','','',18,0,NULL,'',NULL,NULL,NULL,0),(11,'2018-09-18 09:27:15','2018-09-18 09:27:15',NULL,'Nicoletta','MARTINO','','','','',18,0,NULL,'',NULL,NULL,NULL,0);
-/*!40000 ALTER TABLE `teachers` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `the_bosses`
---
-
-DROP TABLE IF EXISTS `the_bosses`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `the_bosses` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-  `created_at` timestamp NULL DEFAULT NULL,
-  `updated_at` timestamp NULL DEFAULT NULL,
-  `deleted_at` timestamp NULL DEFAULT NULL,
-  `name` varchar(255) DEFAULT NULL,
-  `surname` varchar(255) DEFAULT NULL,
-  `username` varchar(255) DEFAULT NULL,
-  `password` varchar(255) DEFAULT NULL,
-  `email` varchar(255) DEFAULT NULL,
-  `telephone_number` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  KEY `idx_the_bosses_deleted_at` (`deleted_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `the_bosses`
---
-
-LOCK TABLES `the_bosses` WRITE;
-/*!40000 ALTER TABLE `the_bosses` DISABLE KEYS */;
-/*!40000 ALTER TABLE `the_bosses` ENABLE KEYS */;
-UNLOCK TABLES;
-/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
-
-/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
-/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
-/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-
--- Dump completed on 2018-10-16  9:38:43

+ 9 - 0
compose/karmen/ldap/Dockerfile

@@ -0,0 +1,9 @@
+FROM osixia/openldap:1.2.1
+MAINTAINER Andrea fazzi <andrea.fazzi@carducci-dante.gov.it>
+
+ADD bootstrap /container/service/slapd/assets/config/bootstrap
+RUN rm /container/service/slapd/assets/config/bootstrap/schema/mmc/mail.schema
+
+# ADD certs /container/service/slapd/assets/certs
+#ADD environment /container/environment/01-custom
+

+ 78 - 0
compose/karmen/ldap/bootstrap/ldif/foo.org.ldif

@@ -0,0 +1,78 @@
+version: 1
+
+dn: ou=Groups,dc=foo,dc=org
+changetype: add
+objectclass: organizationalUnit
+objectclass: top
+ou: Groups
+
+dn: ou=Mailing Lists,ou=Groups,dc=foo,dc=org
+changetype: add
+objectclass: organizationalUnit
+objectclass: top
+ou: Mailing Lists
+
+dn: cn=Teachers,ou=Mailing Lists,ou=Groups,dc=foo,dc=org
+changetype: add
+cn: Teachers
+member: cn=John DOE,ou=People,dc=foo,dc=org
+objectclass: groupOfNames
+objectclass: top
+
+dn: cn=Administratives,ou=Groups,dc=foo,dc=org
+changetype: add
+cn: Administratives
+member: cn=John DOE,ou=People,dc=foo,dc=org
+objectclass: groupOfNames
+objectclass: top
+
+dn: cn=Teachers,ou=Groups,dc=foo,dc=org
+changetype: add
+cn: Teachers
+member: cn=John DOE,ou=People,dc=foo,dc=org
+objectclass: groupOfNames
+objectclass: top
+
+dn: ou=People,dc=foo,dc=org
+changetype: add
+objectclass: organizationalUnit
+objectclass: top
+ou: People
+
+dn: ou=Teachers,ou=People,dc=foo,dc=org
+changetype: add
+objectclass: organizationalUnit
+objectclass: top
+ou: Teachers
+
+dn: ou=Administratives,ou=People,dc=foo,dc=org
+changetype: add
+objectclass: organizationalUnit
+objectclass: top
+ou: Administratives
+
+dn: cn=John DOE,ou=Teachers,ou=People,dc=foo,dc=org
+changetype: add
+cn: John DOE
+gidnumber: 5043
+givenname: John Doe
+homedirectory: /home/users/john.doe
+loginshell: /bin/sh
+mail: john.doe@foo.org
+mailenabled: TRUE
+mailgidnumber: 5000
+mailhomedirectory: /var/mail/foo.org/john.doe/
+mailquota: 10240
+mailstoragedirectory: maildir:/var/mail/foo.org/john.doe/
+mailuidnumber: 5043
+objectclass: inetOrgPerson
+objectclass: posixAccount
+objectclass: top
+objectclass: PostfixBookMailAccount
+objectclass: organizationalPerson
+objectclass: extensibleObject
+sn: DOE
+uid: john.doe
+uidnumber: 5043
+uniqueidentifier: john.doe
+userpassword: {SSHA}hMdtrV6Ai0AUBfnN08x++n12ARvqSsxy

+ 70 - 0
compose/karmen/ldap/bootstrap/schema/postfix-book.schema

@@ -0,0 +1,70 @@
+# $Id$
+#
+# State of Mind
+# Private Enterprise Number: 29426
+#
+# OID prefix: 1.3.6.1.4.1.29426
+#
+# Attributes: 1.3.6.1.4.1.29426.1.10.x
+#
+
+
+attributetype ( 1.3.6.1.4.1.29426.1.10.1 NAME 'mailHomeDirectory'
+	DESC 'The absolute path to the mail user home directory'
+        EQUALITY caseExactIA5Match
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
+
+attributetype ( 1.3.6.1.4.1.29426.1.10.2 NAME 'mailAlias'
+        DESC 'RFC822 Mailbox - mail alias'
+        EQUALITY caseIgnoreIA5Match
+        SUBSTR caseIgnoreIA5SubstringsMatch
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
+
+attributetype ( 1.3.6.1.4.1.29426.1.10.3 NAME 'mailUidNumber'
+        DESC 'UID required to access the mailbox'
+        EQUALITY integerMatch
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attributetype ( 1.3.6.1.4.1.29426.1.10.4 NAME 'mailGidNumber'
+        DESC 'GID required to access the mailbox'
+        EQUALITY integerMatch
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
+
+attributetype ( 1.3.6.1.4.1.29426.1.10.5 NAME 'mailEnabled'
+	DESC 'TRUE to enable, FALSE to disable account'
+        EQUALITY booleanMatch
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )
+
+attributetype ( 1.3.6.1.4.1.29426.1.10.6 NAME 'mailGroupMember'
+	DESC 'Name of a mail distribution list'
+        EQUALITY caseExactIA5Match
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+
+attributetype ( 1.3.6.1.4.1.29426.1.10.7 NAME 'mailQuota'
+	DESC 'Mail quota limit in kilobytes'
+        EQUALITY caseExactIA5Match
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+
+attributetype ( 1.3.6.1.4.1.29426.1.10.8 NAME 'mailStorageDirectory'
+	DESC 'The absolute path to the mail users mailbox'
+        EQUALITY caseExactIA5Match
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
+
+
+#
+# Objects: 1.3.6.1.4.1.29426.1.2.2.x
+#
+
+objectclass ( 1.3.6.1.4.1.29426.1.2.2.1 NAME 'PostfixBookMailAccount'
+        SUP top AUXILIARY
+	DESC 'Mail account used in Postfix Book'
+	MUST ( mail )
+        MAY ( mailHomeDirectory $ mailAlias $ mailGroupMember 
+		$ mailUidNumber $ mailGidNumber $ mailEnabled
+		$ mailQuota $mailStorageDirectory ) )
+
+objectclass ( 1.3.6.1.4.1.29426.1.2.2.2 NAME 'PostfixBookMailForward'
+        SUP top AUXILIARY
+	DESC 'Mail forward used in Postfix Book'
+	MUST ( mail $ mailAlias ))
+

+ 10 - 0
compose/karmen/ldap/environment/my-env.yaml

@@ -0,0 +1,10 @@
+# This is the default image configuration file
+# These values will persists in container environment.
+
+# All environment variables used after the container first start
+# must be defined here.
+# more information : https://github.com/osixia/docker-light-baseimage
+
+# General container configuration
+# see table 5.1 in http://www.openldap.org/doc/admin24/slapdconf2.html for the available log levels.
+LDAP_LOG_LEVEL: 256

ファイルの差分が大きいため隠しています
+ 464 - 464
compose/karmen/sql/karmen_test.sql


+ 29 - 43
cron/sync/sync.go

@@ -71,6 +71,10 @@ type Result struct {
 	Removed []string
 }
 
+func (result *Result) String() string {
+	return fmt.Sprintf("[sync] %d added, %d updated, %d removed", result.Added, result.Updated, result.Removed)
+}
+
 type SyncJob struct {
 	conf *config.ConfigT
 }
@@ -144,7 +148,6 @@ func (syncJob *SyncJob) SyncUsers(ldapClient *karmen_ldap.Client, karmenClient *
 		}
 	}
 
-	log.Println(len(result.Removed), len(result.Added), len(result.Updated))
 	if syncJob.conf.Sync.SendMail {
 		var err error
 
@@ -236,11 +239,11 @@ func (syncJob *SyncJob) SyncUsers(ldapClient *karmen_ldap.Client, karmenClient *
 	return result, nil
 }
 
-func (syncJob *SyncJob) syncGroup(ldapClient *karmen_ldap.Client, groupDN string, users []orm.User) error {
+func (syncJob *SyncJob) SyncGroup(ldapClient *karmen_ldap.Client, users []orm.User, groupDN string) (*Result, error) {
 	actions := make(map[string]*slicediff.Action)
 	entries, err := ldapClient.GroupMembers(groupDN)
 	if err != nil {
-		return err
+		return nil, err
 	}
 
 	values := entries[0].Attributes[0].Values
@@ -251,61 +254,37 @@ func (syncJob *SyncJob) syncGroup(ldapClient *karmen_ldap.Client, groupDN string
 		actions = slicediff.Diff(SliceToStringSlicer(values).Convert, usersToUsernamesConverter(users).Convert)
 	}
 
-	toBeAdded := make([]orm.User, 0)
-	toBeRemoved := make([]string, 0)
+	result := new(Result)
 
 	for _, a := range actions {
 		switch a.Type {
 		case slicediff.Remove:
-			toBeRemoved = append(toBeRemoved, values[a.Id])
+			// entry := entries[a.Id]
+			result.Removed = append(result.Removed, values[a.Id])
 
 		case slicediff.Add:
 			user := users[a.Id]
 			if !user.GetExclude() {
-				toBeAdded = append(toBeAdded, user)
+				result.Added = append(result.Added, user)
 			}
 
 		}
 	}
 
 	if !syncJob.conf.Sync.SafeRun {
-		if len(toBeAdded) > 0 {
-			logf("ADDING %d teachers to %s group", len(toBeAdded), groupDN)
-		}
-		for _, user := range toBeAdded {
-			log.Println(user.CompleteName())
+		for _, user := range result.Added {
 			err = ldapClient.AddUserToGroup(user, groupDN)
 			if err != nil {
-				return err
+				return nil, err
 			}
 		}
-	} else {
-		if len(toBeAdded) > 0 {
-			logf("%d users WOULD BE ADDED to %s group", len(toBeAdded), groupDN)
-		}
-		for _, teacher := range toBeAdded {
-			log.Println(teacher.CompleteName())
-		}
-	}
 
-	if !syncJob.conf.Sync.SafeRun {
-		if len(toBeRemoved) > 0 {
-			logf("REMOVING %d users from %s group...", len(toBeRemoved), groupDN)
-		}
-		for _, value := range toBeRemoved {
-			logf("REMOVE %s from %s group.", value, groupDN)
+		for _, value := range result.Removed {
 			ldapClient.RemoveUserFromGroupByMemberValue(value, groupDN)
 		}
-	} else {
-		if len(toBeRemoved) > 0 {
-			logf("%d users WOULD BE REMOVED FROM %s group", len(toBeRemoved), groupDN)
-		}
-		for _, entry := range toBeRemoved {
-			log.Println(entry)
-		}
 	}
 
-	return nil
+	return result, nil
 }
 
 func (syncJob *SyncJob) Run() {
@@ -347,18 +326,24 @@ func (syncJob *SyncJob) Run() {
 		users = append(users, teacher)
 	}
 	log.Println("Sync teachers...")
-	if _, err := syncJob.SyncUsers(ldapClient, karmenClient, entries, users); err != nil {
+	if result, err := syncJob.SyncUsers(ldapClient, karmenClient, entries, users); err != nil {
 		panic(err)
+	} else {
+		log.Println(result)
 	}
 
 	log.Println("Sync 'Docenti' group...")
-	if err := syncJob.syncGroup(ldapClient, "cn=Docenti", users); err != nil {
+	if result, err := syncJob.SyncGroup(ldapClient, users, "cn=Docenti"); err != nil {
 		panic(err)
+	} else {
+		log.Println(result)
 	}
 
 	log.Println("Sync 'Tutti i docenti' ML...")
-	if err := syncJob.syncGroup(ldapClient, "cn=Tutti i docenti,ou=Mailing Lists", users); err != nil {
+	if result, err := syncJob.SyncGroup(ldapClient, users, "cn=Tutti i docenti,ou=Mailing Lists"); err != nil {
 		panic(err)
+	} else {
+		log.Println(result)
 	}
 
 	log.Println("Sync Departments and MLs...")
@@ -368,15 +353,16 @@ func (syncJob *SyncJob) Run() {
 			users = append(users, teacher)
 		}
 		group := fmt.Sprintf("cn=%s,ou=Mailing Lists", department.Name)
-		err = syncJob.syncGroup(ldapClient, group, users)
-		if err != nil {
+		if result, err := syncJob.SyncGroup(ldapClient, users, group); err != nil {
 			panic(err)
+		} else {
+			log.Println(result)
 		}
 		group = fmt.Sprintf("cn=%s,ou=Dipartimenti", department.Name)
-		err = syncJob.syncGroup(ldapClient, group, users)
-		if err != nil {
+		if result, err := syncJob.SyncGroup(ldapClient, users, group); err != nil {
 			panic(err)
+		} else {
+			log.Println(result)
 		}
-
 	}
 }

+ 27 - 1
cron/sync/test/karmen_test_sync/image/bootstrap/ldif/foo.org.ldif

@@ -19,13 +19,39 @@ member: cn=John DOE,ou=People,dc=foo,dc=org
 objectclass: groupOfNames
 objectclass: top
 
+dn: cn=Administratives,ou=Groups,dc=foo,dc=org
+changetype: add
+cn: Administratives
+member: cn=John DOE,ou=People,dc=foo,dc=org
+objectclass: groupOfNames
+objectclass: top
+
+dn: cn=Teachers,ou=Groups,dc=foo,dc=org
+changetype: add
+cn: Teachers
+member: cn=John DOE,ou=People,dc=foo,dc=org
+objectclass: groupOfNames
+objectclass: top
+
 dn: ou=People,dc=foo,dc=org
 changetype: add
 objectclass: organizationalUnit
 objectclass: top
 ou: People
 
-dn: cn=John DOE,ou=People,dc=foo,dc=org
+dn: ou=Teachers,ou=People,dc=foo,dc=org
+changetype: add
+objectclass: organizationalUnit
+objectclass: top
+ou: Teachers
+
+dn: ou=Administratives,ou=People,dc=foo,dc=org
+changetype: add
+objectclass: organizationalUnit
+objectclass: top
+ou: Administratives
+
+dn: cn=John DOE,ou=Teachers,ou=People,dc=foo,dc=org
 changetype: add
 cn: John DOE
 gidnumber: 5043

ファイルの差分が大きいため隠しています
+ 4 - 2
cron/sync/test/karmen_test_sync/sql/karmen_test.sql


+ 73 - 18
cron/sync/test/sync_test.go

@@ -64,7 +64,7 @@ func (t *testSuite) TestSyncUsers() {
 	teachers, err := karmen.GetTeachers()
 	t.Nil(err)
 
-	entries, err := ldap.Users("ou=People,dc=foo,dc=org")
+	entries, err := ldap.Users("ou=Teachers,ou=People,dc=foo,dc=org")
 	t.Nil(err)
 
 	users := make([]orm.User, 0)
@@ -75,18 +75,20 @@ func (t *testSuite) TestSyncUsers() {
 	result, err := syncJob.SyncUsers(ldap, karmen, entries, users)
 	t.Nil(err)
 
-	t.Equal(len(result.Added), 11)
-	t.Equal(len(result.Updated), 0)
-	t.Equal(len(result.Removed), 1)
+	if !t.Failed() {
+		t.Equal(len(result.Added), 11)
+		t.Equal(len(result.Updated), 0)
+		t.Equal(len(result.Removed), 1)
 
-	t.Equal(result.Removed[0], "cn=John DOE,ou=People,dc=foo,dc=org")
+		t.Equal(result.Removed[0], "cn=John DOE,ou=Teachers,ou=People,dc=foo,dc=org")
+	}
 
 	// Run sync two times should result in no updating
 
 	teachers, err = karmen.GetTeachers()
 	t.Nil(err)
 
-	entries, err = ldap.Users("ou=People,dc=foo,dc=org")
+	entries, err = ldap.Users("ou=Teachers,ou=People,dc=foo,dc=org")
 	t.Nil(err)
 
 	users = make([]orm.User, 0)
@@ -103,22 +105,75 @@ func (t *testSuite) TestSyncUsers() {
 		t.Equal(len(result.Removed), 0)
 	}
 
-	// // Update user and test LDAP sync
+	// Update user and test LDAP sync
 
-	// user := teachers[0]
+	user := teachers[0]
 
-	// user.SetRegenerate(true)
+	user.SetRegenerate(true)
 
-	// err = karmen.UpdateUser(user)
-	// t.Nil(err)
+	err = karmen.UpdateUser(user)
+	t.Nil(err)
 
-	// result, err = syncJob.SyncUsers(ldap, karmen, entries, users)
-	// t.Nil(err)
+	teachers, err = karmen.GetTeachers()
+	t.Nil(err)
 
-	// if !t.Failed() {
-	// 	t.Equal(len(result.Added), 0)
-	// 	t.Equal(len(result.Updated), 1)
-	// 	t.Equal(len(result.Removed), 0)
-	// }
+	entries, err = ldap.Users("ou=Teachers,ou=People,dc=foo,dc=org")
+	t.Nil(err)
 
+	users = make([]orm.User, 0)
+	for _, teacher := range teachers {
+		users = append(users, teacher)
+	}
+	result, err = syncJob.SyncUsers(ldap, karmen, entries, users)
+	t.Nil(err)
+
+	if !t.Failed() {
+		t.Equal(len(result.Added), 0)
+		t.Equal(len(result.Updated), 1)
+		t.Equal(len(result.Removed), 0)
+	}
+
+	// Sync administratives
+
+	administratives, err := karmen.GetAdministratives()
+	t.Nil(err)
+
+	entries, err = ldap.Users("ou=Administratives,ou=People,dc=foo,dc=org")
+	t.Nil(err)
+
+	users = make([]orm.User, 0)
+	for _, administrative := range administratives {
+		users = append(users, administrative)
+	}
+
+	result, err = syncJob.SyncUsers(ldap, karmen, entries, users)
+	t.Nil(err)
+
+	if !t.Failed() {
+		t.Equal(2, len(result.Added))
+		t.Equal(0, len(result.Updated))
+		t.Equal(0, len(result.Removed))
+	}
+
+}
+
+func (t *testSuite) TestSyncGroup() {
+	syncJob := sync.NewSyncJob(conf)
+
+	teachers, err := karmen.GetTeachers()
+	t.Nil(err)
+
+	users := make([]orm.User, 0)
+	for _, teacher := range teachers {
+		users = append(users, teacher)
+	}
+
+	result, err := syncJob.SyncGroup(ldap, users, "cn=Teachers")
+	t.Nil(err)
+
+	if !t.Failed() {
+		t.Equal(11, len(result.Added))
+		t.Equal(0, len(result.Updated))
+		t.Equal(1, len(result.Removed))
+	}
 }

+ 4 - 0
orm/administrative.go

@@ -157,3 +157,7 @@ func GetAdministrativeForAdd(args map[string]string) (interface{}, error) {
 func (s *Administrative) CompleteName() string {
 	return fmt.Sprintf("%s %s", s.Name, s.Surname)
 }
+
+func (t *Administrative) RestAPIPath() string {
+	return "administratives"
+}

+ 6 - 1
templates/administratives_add_update.html.tpl

@@ -83,7 +83,7 @@
 
     <div class="form-group">
       <label class="control-label" for="office_id">Associato all'ufficio</label>
-      <select name="office_id" class="form-control selectpicker" id="office_id" placeholder="Seleziona l'ufficio" data-live-search="true" form="form_administratives_add_update" title="Seleziona l'ufficio" data-dropup-auto="false" required>
+      <select name="office_id" class="form-control selectpicker" id="office_id" placeholder="Seleziona l'ufficio" data-live-search="true" form="form_administratives_add_update" title="Seleziona l'ufficio" data-dropup-auto="false">
     	<option value="0"></option>
     	{{range $office := .Data.AllOffices}}
     	{{if $.Options.Get "update"}}
@@ -98,6 +98,11 @@
       </select>
     </div>
 
+    <div class="form-group">
+      <label class="control-label has-feedback" for="administrative_ldapdnfmt">Stringa DN per LDAP</label>
+      <input type="text" name="LdapDNFmt" class="form-control" id="administrative_ldapdnfmt" placeholder="cn=%s %s,ou=People,dc=foo,dc=org" {{if .Options.Get "update"}}value="{{.Data.Administrative.LdapDNFmt}}"{{end}}>
+    </div>
+
     <div class="form-group">
       <button type="submit" class="btn btn-primary">Salva</button>
       {{if .Options.Get "update"}}

+ 1 - 1
templates/teachers_add_update.html.tpl

@@ -78,7 +78,7 @@
 
     <div class="form-group">
       <label class="control-label has-feedback" for="teacher_ldapdnfmt">Stringa DN per LDAP</label>
-      <input type="text" name="LdapDNFmt" class="form-control" id="teacher_ldapdnfmt" placeholder="cn=%s %s,dc=foo,dc=org" {{if .Options.Get "update"}}value="{{.Data.LdapDNFmt}}"{{end}}>
+      <input type="text" name="LdapDNFmt" class="form-control" id="teacher_ldapdnfmt" placeholder="cn=%s %s,ou=People,dc=foo,dc=org" {{if .Options.Get "update"}}value="{{.Data.LdapDNFmt}}"{{end}}>
     </div>
 
     <div class="form-group">

+ 25 - 0
vendor/gogs.carducci-dante.gov.it/karmen/client/client.go

@@ -116,6 +116,31 @@ func (c *Client) GetTeachers() ([]*orm.Teacher, error) {
 	return teachers, nil
 }
 
+func (c *Client) GetAdministratives() ([]*orm.Administrative, error) {
+	var (
+		response        renderer.JsonResponse
+		administratives []*orm.Administrative
+	)
+
+	data, err := c.SendRequest("GET", "/api/administratives?format=json", nil)
+	if err != nil {
+		return nil, err
+	}
+
+	if err := json.Unmarshal(data, &response); err != nil {
+		return nil, err
+	}
+
+	if string(response.Error) != "" {
+		return nil, errors.New(string(response.Error))
+	}
+
+	if err := json.Unmarshal(response.Result, &administratives); err != nil {
+		return nil, err
+	}
+	return administratives, nil
+}
+
 func (c *Client) GetTeacher(id uint) (*orm.Teacher, error) {
 	var (
 		response renderer.JsonResponse

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません