This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/passbook/sources/ldap/migrations/0003_auto_20191011_0825.py

33 lines
983 B
Python

# Generated by Django 2.2.6 on 2019-10-11 08:25
from django.apps.registry import Apps
from django.db import migrations
def create_default_ad_property_mappings(apps: Apps, schema_editor):
LDAPPropertyMapping = apps.get_model("passbook_sources_ldap", "LDAPPropertyMapping")
mapping = {
"name": "name",
"givenName": "first_name",
"sn": "last_name",
"sAMAccountName": "username",
"mail": "email",
}
for ldap_property, object_field in mapping.items():
LDAPPropertyMapping.objects.get_or_create(
ldap_property=ldap_property,
object_field=object_field,
defaults={
"name": f"Autogenerated LDAP Mapping: {ldap_property} -> {object_field}"
},
)
class Migration(migrations.Migration):
dependencies = [
("passbook_sources_ldap", "0002_auto_20191011_0825"),
]
operations = [migrations.RunPython(create_default_ad_property_mappings)]