s4:dsdb: Move the responsibility for determining whether an account is a gMSA out...
authorJo Sutton <josutton@catalyst.net.nz>
Wed, 17 Apr 2024 01:27:19 +0000 (13:27 +1200)
committerJo Sutton <jsutton@samba.org>
Sun, 21 Apr 2024 22:10:36 +0000 (22:10 +0000)
and into its callers.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/gmsa/util.c
source4/dsdb/gmsa/util.h

index ef67f6c162f1169da9d248f007ed1555eb75f043..4397219eb78c57bf6ed20fda881ede4947fd26b2 100644 (file)
@@ -1108,6 +1108,15 @@ static bool samdb_result_gkdi_rollover_interval(const struct ldb_message *msg,
                                      rollover_interval_out);
 }
 
+/*
+ * Recalculate the managed password of an account. The account referred to by
+ * ‘msg’ should be a Group Managed Service Account.
+ *
+ * Updated passwords are returned in ‘update_out’.
+ *
+ * Pass in a non‐NULL pointer for ‘return_out’ if you want the passwords as
+ * reflected by the msDS-ManagedPassword operational attribute.
+ */
 int gmsa_recalculate_managed_pwd(TALLOC_CTX *mem_ctx,
                                 struct ldb_context *ldb,
                                 const struct ldb_message *msg,
@@ -1143,20 +1152,6 @@ int gmsa_recalculate_managed_pwd(TALLOC_CTX *mem_ctx,
        }
        *update_out = NULL;
 
-       {
-               /* Is the account a Group Managed Service Account? */
-               const bool is_gmsa = dsdb_account_is_gmsa(ldb, msg);
-               if (!is_gmsa) {
-                       /* It’s not a GMSA — we’re done here. */
-                       *update_out = NULL;
-                       if (return_out != NULL) {
-                               *return_out = (struct gmsa_return_pwd){};
-                       }
-                       ret = LDB_SUCCESS;
-                       goto out;
-               }
-       }
-
        /* Calculate the rollover interval. */
        ok = samdb_result_gkdi_rollover_interval(msg, &rollover_interval);
        if (!ok || rollover_interval == 0) {
index ef14b423f3bee58f5cb24f2fdbd1445b498d95bc..371bdf2c5946bb1cdb7ff47f9ba0e91e17cd04ec 100644 (file)
@@ -99,6 +99,15 @@ struct gmsa_return_pwd {
        NTTIME unchanged_interval;
 };
 
+/*
+ * Recalculate the managed password of an account. The account referred to by
+ * ‘msg’ should be a Group Managed Service Account.
+ *
+ * Updated passwords are returned in ‘update_out’.
+ *
+ * Pass in a non‐NULL pointer for ‘return_out’ if you want the passwords as
+ * reflected by the msDS-ManagedPassword operational attribute.
+ */
 int gmsa_recalculate_managed_pwd(TALLOC_CTX *mem_ctx,
                                 struct ldb_context *ldb,
                                 const struct ldb_message *msg,