title: Getting Access denied when accessing PrincipalContext on remote machine with a known good login
body: <p>I'm trying to add a domain account to a remote computer's Administrators group. The problem I'm having is that when I try to actually connect to the remote machine PrincipleContext, it gives me an access denied message, but I'm connecting as the remote machine local admin. When I try to access it though I get <strong>"Access is denied"</strong>. I know the login is correct, because if I change it I get a bad password/username error instead.</p>
  
  <p>The Administrator account is the true admin account, and I can login to the local box with the account and I have full admin access, I can add users as needed without any issue to the Administrators group. Any ideas what would cause it to report Access is Denied when trying to do this remotely?</p>
  
  <pre><code>try
        {
          using (PrincipalContext pc = new PrincipalContext(ContextType.Machine, "SERVER_IP_HERE", null, ContextOptions.Negotiate, @"RemoteMachineNameHere\Administrator", "MyPassword"))
          {
            //Get an access denied error here trying to connect to the Context
            GroupPrincipal group = GroupPrincipal.FindByIdentity(pc, "Administrators");
            PrincipalContext dom1PC = new PrincipalContext(ContextType.Domain, "FQDNOFDomainHere");
            var me = UserPrincipal.FindByIdentity(dom1PC, IdentityType.SamAccountName, @"MyUserName");
            group.Members.Add(me);
            group.Save();
          }
        }
        catch (System.DirectoryServices.DirectoryServicesCOMException E)
        {
          Console.WriteLine(e);
  
        } 
  </code></pre>