Quantcast
Viewing all articles
Browse latest Browse all 3260

Active Directory error "-2147016672"

Hi,

I am creating a script in ASP.NET C# to invoke cmdlets from Lync Server.

I want just list a user : Get-CsUSer and when i run the script i received the follow error code:

Active Directory error "-2147016672" occurred while searching for domain controllers in domain .

I run my script from my local machine developer (it is remote) to the server. The script is :

Runspace remoteRunspace = null;
            openRunspace("servidor:5985/wsman", "http://schemas.microsoft.com/powershell/Microsoft.PowerShell",
                 @"\user", "senha", ref remoteRunspace);

            using (PowerShell powershell = PowerShell.Create())
            {
                powershell.Runspace = remoteRunspace;

                powershell.AddScript("Import-Module Lync"); //funciona
                powershell.Invoke();

                Pipeline pipeline = remoteRunspace.CreatePipeline();
                string remoteScript = "Get-CsUser -Identity mmiranda";
                pipeline.Commands.AddScript(remoteScript);

                Collection<PSObject> results = pipeline.Invoke();

                remoteRunspace.Close();

                return results;

            }

public static void openRunspace(string uri, string schema, string username, string livePass, ref Runspace remoteRunspace)
        {
            System.Security.SecureString password = new System.Security.SecureString();
            foreach (char c in livePass.ToCharArray())
            {
                password.AppendChar(c);
            }
            PSCredential psc = new PSCredential(username, password);
            WSManConnectionInfo rri = new WSManConnectionInfo(new Uri(uri), schema, psc);
            //rri.AuthenticationMechanism = AuthenticationMechanism.Default;
            //rri.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
            //rri.AuthenticationMechanism = AuthenticationMechanism.Basic;
            //rri.NoEncryption = true;
            rri.ProxyAuthentication = AuthenticationMechanism.Negotiate;
            remoteRunspace = RunspaceFactory.CreateRunspace(rri);
            remoteRunspace.Open();


        }

i don't know what to do anymore.

Help me.

My e-mail gersonczjr@hotmail.com

thx


Viewing all articles
Browse latest Browse all 3260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>