Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Impersonating operations

    Scheduled Pinned Locked Moved Support
    otter
    6 Posts 1 Posters 13 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ? This user is from outside of this forum
      Guest
      last edited by

      By default, operations will be performed as the user that the agent service runs as (Local System). I am trying to perform some group and user operations using PSDsc. Because this DSC operation must reach out to the domain, it will not have domain rights to query the members being added to the group.

      PSDsc Group
      (
          Otter_ConfigurationKey: CreateDummyGroup,
          GroupName: DummyGroupCreatedByOtter,
          Ensure: Present,
          Description: Test using PSDsc from Otter,
          Members: "`@('mydomain\myuser')"
      );
      

      This will produce the error:

      PowerShell DSC resource MSFT_GroupResource failed to execute Set-TargetResource functionality with error message: Credentials are required to resolve the domain account mydomain\myuser.

      Perhaps allowing General blocks to execute with specific credentials (impersonate) might be a solution? I have done this type of impersonation in PowerShell, and found that a different type of impersonation is required to perform network operations.

      I think offering impersonation may offer a better solution than running agents as a domain user, as it is by default low privileged, and only impersonate when absolutely needed.

      1 Reply Last reply Reply Quote 0
      • ? This user is from outside of this forum
        Guest
        last edited by

        The 'Group' DSC resource does accept a 'Credential' parameter, but I am not sure how to pass an Otter credential into that, as the PSDsc only supports strings, arrays, booleans, decimals and hashes for parameter values.

        1 Reply Last reply Reply Quote 0
        • ? This user is from outside of this forum
          Guest
          last edited by

          Unfortunately, impersonation is not trivial complicated, especially with the hosted powershell model. It's definitely doable -- and the new agent model would support launching different sub-agents under a different user -- but we looked to the "sudo problem" when consideration solution.

          That is, if the automation tool easily has the capability to elevate permissions, then it effectively always has those permissions, because you're /automatically elevating/ to a different level. At best, it may prevent a typo in an automation script... but, it isn't a great security thing.

          Regarding the question, you can use the GetCredentialProperty variable unction to extract the password property from a credential stored in otter and pass to script.

          1 Reply Last reply Reply Quote 0
          • ? This user is from outside of this forum
            Guest
            last edited by

            Regarding the question, you can use the GetCredentialProperty variable function to extract the password property from a credential stored in otter and pass to script.

            The problem is, in this instance, I need to pass an actual PSCredential object into the "Credential" parameter of the DSC resource. Is there a way to accomplish this in Otter without creating a custom PowerShell script to invoke the DSC resource?

            1 Reply Last reply Reply Quote 0
            • ? This user is from outside of this forum
              Guest
              last edited by

              You know, I believe this came up at one point, in this GitHub issue. So, it's not implemented... but do you think it could work?

              set $password = $GetCredentialProperty(mysecret, password);
              
              PSDsc Group
              (
                  Otter_ConfigurationKey: CreateDummyGroup,
                  GroupName: DummyGroupCreatedByOtter,
                  Ensure: Present,
                  Description: Test using PSDsc from Otter,
                  Members: "`@('mydomain\myuser')",
                  Credential: $ToPsCredential(someusername, $password)
              );
              
              1 Reply Last reply Reply Quote 0
              • ? This user is from outside of this forum
                Guest
                last edited by

                Sure, that would solve the issue.

                1 Reply Last reply Reply Quote 0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • 1 / 1
                • First post
                  Last post
                Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation