netcmd: models: Add Person and OrganizationalPerson
authorRob van der Linde <rob@catalyst.net.nz>
Tue, 27 Feb 2024 01:12:40 +0000 (14:12 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 1 Mar 2024 04:45:36 +0000 (04:45 +0000)
Move only those fields over that we already had on User that actually belong on Person and OrganizationalPerson

There are more fields to add later.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/netcmd/domain/models/__init__.py
python/samba/netcmd/domain/models/person.py [new file with mode: 0644]
python/samba/netcmd/domain/models/user.py

index c84380b9b6ae2d90c233a5a368e28e8af58df94a..4e100574aaf37190b5ad76d1e3ddccfef1cfe139 100644 (file)
@@ -29,6 +29,7 @@ from .constants import MODELS
 from .gmsa import GroupManagedServiceAccount
 from .group import Group
 from .model import Model
+from .person import OrganizationalPerson, Person
 from .schema import AttributeSchema, ClassSchema
 from .site import Site
 from .subnet import Subnet
diff --git a/python/samba/netcmd/domain/models/person.py b/python/samba/netcmd/domain/models/person.py
new file mode 100644 (file)
index 0000000..8e68c80
--- /dev/null
@@ -0,0 +1,41 @@
+# Unix SMB/CIFS implementation.
+#
+# Person and OrganisationalPerson models.
+#
+# Copyright (C) Catalyst.Net Ltd. 2024
+#
+# Written by Rob van der Linde <rob@catalyst.net.nz>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+from .fields import IntegerField, StringField
+from .model import Model
+
+
+class Person(Model):
+    sn = StringField("sn")
+
+    @staticmethod
+    def get_object_class():
+        return "person"
+
+
+class OrganizationalPerson(Person):
+    country_code = IntegerField("countryCode")
+    given_name = StringField("givenName")
+
+    @staticmethod
+    def get_object_class():
+        return "organizationalPerson"
index 151fbfab5d3747971e732dae638090500db76f13..a3fc2677fbd1acf35d2d2b0e1d885bd2cd2659e9 100644 (file)
@@ -25,11 +25,11 @@ from ldb import Dn
 from samba.dsdb import DS_GUID_USERS_CONTAINER
 
 from .fields import DnField, EnumField, IntegerField, NtTimeField, StringField
-from .model import Model
+from .person import OrganizationalPerson
 from .types import AccountType, UserAccountControl
 
 
-class User(Model):
+class User(OrganizationalPerson):
     username = StringField("sAMAccountName")
     account_type = EnumField("sAMAccountType", AccountType)
     assigned_policy = DnField("msDS-AssignedAuthNPolicy")
@@ -37,10 +37,7 @@ class User(Model):
     bad_password_time = NtTimeField("badPasswordTime", readonly=True)
     bad_pwd_count = IntegerField("badPwdCount", readonly=True)
     code_page = IntegerField("codePage")
-    country_code = IntegerField("countryCode")
     display_name = StringField("displayName")
-    given_name = StringField("givenName")
-    sn = StringField("sn")
     last_logoff = NtTimeField("lastLogoff", readonly=True)
     last_logon = NtTimeField("lastLogon", readonly=True)
     logon_count = IntegerField("logonCount", readonly=True)