From 7fb90fdc4c8de1d9768744dae18dfa8db56d56b4 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Mon, 26 Jun 2017 22:23:58 +0200 Subject: [PATCH] Ajoute un champ dialup access --- .../migrations/0052_ldapuser_shadowexpire.py | 21 +++++++++++++++++++ users/migrations/0053_auto_20170626_2105.py | 21 +++++++++++++++++++ users/migrations/0054_auto_20170626_2219.py | 21 +++++++++++++++++++ users/models.py | 9 ++++++-- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 users/migrations/0052_ldapuser_shadowexpire.py create mode 100644 users/migrations/0053_auto_20170626_2105.py create mode 100644 users/migrations/0054_auto_20170626_2219.py diff --git a/users/migrations/0052_ldapuser_shadowexpire.py b/users/migrations/0052_ldapuser_shadowexpire.py new file mode 100644 index 00000000..fa818004 --- /dev/null +++ b/users/migrations/0052_ldapuser_shadowexpire.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-06-26 18:51 +from __future__ import unicode_literals + +from django.db import migrations +import ldapdb.models.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0051_user_telephone'), + ] + + operations = [ + migrations.AddField( + model_name='ldapuser', + name='shadowexpire', + field=ldapdb.models.fields.CharField(blank=True, db_column='shadowExpire', max_length=200, null=True), + ), + ] diff --git a/users/migrations/0053_auto_20170626_2105.py b/users/migrations/0053_auto_20170626_2105.py new file mode 100644 index 00000000..03a23f12 --- /dev/null +++ b/users/migrations/0053_auto_20170626_2105.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-06-26 19:05 +from __future__ import unicode_literals + +from django.db import migrations +import ldapdb.models.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0052_ldapuser_shadowexpire'), + ] + + operations = [ + migrations.AlterField( + model_name='ldapuser', + name='shadowexpire', + field=ldapdb.models.fields.IntegerField(blank=True, db_column='shadowExpire', null=True), + ), + ] diff --git a/users/migrations/0054_auto_20170626_2219.py b/users/migrations/0054_auto_20170626_2219.py new file mode 100644 index 00000000..b22d1e1f --- /dev/null +++ b/users/migrations/0054_auto_20170626_2219.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-06-26 20:19 +from __future__ import unicode_literals + +from django.db import migrations +import ldapdb.models.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0053_auto_20170626_2105'), + ] + + operations = [ + migrations.AlterField( + model_name='ldapuser', + name='shadowexpire', + field=ldapdb.models.fields.CharField(blank=True, db_column='shadowExpire', max_length=200, null=True), + ), + ] diff --git a/users/models.py b/users/models.py index 73cb3b99..1c3a9f30 100644 --- a/users/models.py +++ b/users/models.py @@ -360,7 +360,11 @@ class User(AbstractBaseUser): user_ldap.user_password = self.password[:6] + self.password[7:] user_ldap.sambat_nt_password = self.pwd_ntlm.upper() if self.shell: - user_ldap.login_shell = self.shell.shell + user_ldap.login_shell = self.shell.shell + if self.state == self.STATE_DISABLED: + user_ldap.shadowexpire = str(0) + else: + user_ldap.shadowexpire = None if access_refresh: user_ldap.dialupAccess = str(self.has_access) if mac_refresh: @@ -599,7 +603,7 @@ class LdapUser(ldapdb.models.Model): """ # LDAP meta-data base_dn = LDAP['base_user_dn'] - object_classes = ['inetOrgPerson','top','posixAccount','sambaSamAccount','radiusprofile'] + object_classes = ['inetOrgPerson','top','posixAccount','sambaSamAccount','radiusprofile', 'shadowAccount'] # attributes gid = ldapdb.models.fields.IntegerField(db_column='gidNumber') @@ -617,6 +621,7 @@ class LdapUser(ldapdb.models.Model): user_password = ldapdb.models.fields.CharField(db_column='userPassword', max_length=200, blank=True, null=True) sambat_nt_password = ldapdb.models.fields.CharField(db_column='sambaNTPassword', max_length=200, blank=True, null=True) macs = ldapdb.models.fields.ListField(db_column='radiusCallingStationId', max_length=200, blank=True, null=True) + shadowexpire = ldapdb.models.fields.CharField(db_column='shadowExpire', blank=True, null=True) def __str__(self): return self.name