如何在连接到 HPC 调度程序时以编程方式设置用户密码凭据

How to programatically set user password credentials when connecting to an HPC Scheduler

我正在尝试在 HPC Server 2019 集群上安排作业。我想这样做而不必输入我正在使用的服务帐户的密码。下面是代码,但是没有注释它无法连接的代码行

        string userName = GetKeyVaultSecret("ServiceAccount");
        string password = GetKeyVaultSecret("ServiceAccountPassword");

        using (IScheduler scheduler = new Scheduler())
        {
            try
            {
                    // Connect to the scheduler as another user
                    Console.WriteLine("Connecting to {0} as {1}...", clusterName, userName);
                    scheduler.SetCachedCredentials(userName,password); // If I comment this line I am prompted for a password and it connects
                    scheduler.ConnectServiceAsClient(clusterName, () => userName);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Could not connect to the scheduler: {0}", e.Message);
                if (e.InnerException != null) Console.WriteLine(e.InnerException.Message.ToString());
                return 1; 
            }

错误是我不应该在这里设置用户名和密码,但是当我提交作业时

        scheduler.SubmitJob(job, @"domain\" + userName, password);