From: Rob van der Linde Date: Tue, 27 Feb 2024 23:20:24 +0000 (+1300) Subject: netcmd: claims: tidy up, avoid setting enabled twice X-Git-Tag: tdb-1.4.11~1548 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d7cbba23ef4ea6640553e3175243a82db390f8a;p=thirdparty%2Fsamba.git netcmd: claims: tidy up, avoid setting enabled twice Signed-off-by: Rob van der Linde Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/netcmd/domain/claim/claim_type.py b/python/samba/netcmd/domain/claim/claim_type.py index 092cd4aa46c..632de005cad 100644 --- a/python/samba/netcmd/domain/claim/claim_type.py +++ b/python/samba/netcmd/domain/claim/claim_type.py @@ -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)