]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tests/krb5: Allow creating Group Managed Service Accounts
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 13 Nov 2023 04:07:02 +0000 (17:07 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 16 Nov 2023 05:18:36 +0000 (05:18 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/krb5/kdc_base_test.py

index 7a1479edc05b07de098fa9080c55f26dde7868f3..17d6454052466a7a2135112398e1c731945811c7 100644 (file)
@@ -157,6 +157,7 @@ class KDCBaseTest(TestCaseInTempDir, RawKerberosTest):
         SERVER = object()
         RODC = object()
         MANAGED_SERVICE = object()
+        GROUP_MANAGED_SERVICE = object()
 
     @classmethod
     def setUpClass(cls):
@@ -801,7 +802,8 @@ class KDCBaseTest(TestCaseInTempDir, RawKerberosTest):
         if ou is None:
             if account_type is self.AccountType.COMPUTER:
                 guid = DS_GUID_COMPUTERS_CONTAINER
-            elif account_type is self.AccountType.MANAGED_SERVICE:
+            elif account_type is self.AccountType.MANAGED_SERVICE or (
+                    account_type is self.AccountType.GROUP_MANAGED_SERVICE):
                 guid = DS_GUID_MANAGED_SERVICE_ACCOUNTS_CONTAINER
             elif account_type is self.AccountType.SERVER:
                 guid = DS_GUID_DOMAIN_CONTROLLERS_CONTAINER
@@ -826,6 +828,10 @@ class KDCBaseTest(TestCaseInTempDir, RawKerberosTest):
             object_class = "msDS-ManagedServiceAccount"
             account_control |= UF_WORKSTATION_TRUST_ACCOUNT
             secure_schannel_type = SEC_CHAN_WKSTA
+        elif account_type is self.AccountType.GROUP_MANAGED_SERVICE:
+            object_class = "msDS-GroupManagedServiceAccount"
+            account_control |= UF_WORKSTATION_TRUST_ACCOUNT
+            secure_schannel_type = SEC_CHAN_WKSTA
         else:
             object_class = "computer"
             if account_type is self.AccountType.COMPUTER:
@@ -837,15 +843,21 @@ class KDCBaseTest(TestCaseInTempDir, RawKerberosTest):
             else:
                 self.fail()
 
-        password = generate_random_password(32, 32)
-        utf16pw = ('"%s"' % password).encode('utf-16-le')
-
         details = {
             "dn": dn,
             "objectClass": object_class,
             "sAMAccountName": account_name,
             "userAccountControl": str(account_control),
-            "unicodePwd": utf16pw}
+        }
+
+        if account_type is self.AccountType.GROUP_MANAGED_SERVICE:
+            password = None
+        else:
+            password = generate_random_password(32, 32)
+            utf16pw = ('"%s"' % password).encode('utf-16-le')
+
+            details['unicodePwd'] = utf16pw
+
         if upn is not None:
             upn = upn.format(account=account_name)
         if spn is not None:
@@ -897,7 +909,8 @@ class KDCBaseTest(TestCaseInTempDir, RawKerberosTest):
         creds.guess(self.get_lp())
         creds.set_realm(samdb.domain_dns_name().upper())
         creds.set_domain(samdb.domain_netbios_name().upper())
-        creds.set_password(password)
+        if password is not None:
+            creds.set_password(password)
         creds.set_username(account_name)
         if account_type is self.AccountType.USER:
             creds.set_workstation('')