netcmd: claims: tidy up, avoid setting enabled twice
authorRob van der Linde <rob@catalyst.net.nz>
Tue, 27 Feb 2024 23:20:24 +0000 (12:20 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 1 Mar 2024 04:45:36 +0000 (04:45 +0000)
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/claim/claim_type.py

index 092cd4aa46c7cfd184e328d58c7bb20c7929078e..632de005cadbfc6fff26b1c381f8e5d4365de2e6 100644 (file)
@@ -86,6 +86,13 @@ class cmd_domain_claim_claim_type_create(Command):
             raise CommandError(f"Claim type {display_name} already exists, "
                                "but you can use --name to use another name.")
 
+        # Either --enable will be set or --disable but never both.
+        # The default if both are missing is enabled=True.
+        if enable is not None:
+            enabled = enable
+        else:
+            enabled = not disable
+
         # Lookup attribute and class names in schema.
         try:
             applies_to = [ClassSchema.find(ldb, name) for name in class_names]
@@ -109,7 +116,7 @@ class cmd_domain_claim_claim_type_create(Command):
             cn=cn,
             description=description,
             display_name=display_name,
-            enabled=not disable,
+            enabled=enabled,
             claim_attribute_source=attribute.dn,
             claim_is_single_valued=attribute.is_single_valued,
             claim_is_value_space_restricted=False,
@@ -118,13 +125,6 @@ class cmd_domain_claim_claim_type_create(Command):
             claim_value_type=value_type.claim_value_type,
         )
 
-        # Either --enable will be set or --disable but never both.
-        # The default if both are missing is enabled=True.
-        if enable is not None:
-            claim_type.enabled = enable
-        else:
-            claim_type.enabled = not disable
-
         # Create claim type
         try:
             claim_type.save(ldb)