/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { //If not running elevated, then throw an "elevation required" error message. WSManHelper.ThrowIfNotAdministrator(); helper = new WSManHelper(this); #if !CORECLR if (Environment.OSVersion.Version.Major < 6) { //OS is XP/Win2k3. Throw error. string message = helper.FormatResourceMsgFromResourcetext("CmdletNotAvailable"); throw new InvalidOperationException(message); } #endif //If not running elevated, then throw an "elevation required" error message. WSManHelper.ThrowIfNotAdministrator(); // DelegateComputer cannot be specified when Role is other than client if ((delegatecomputer != null) && !Role.Equals(Client, StringComparison.OrdinalIgnoreCase)) { string message = helper.FormatResourceMsgFromResourcetext("CredSSPRoleAndDelegateCannotBeSpecified", "DelegateComputer", "Role", Role, Client); throw new InvalidOperationException(message); } // DelegateComputer must be specified when Role is client if (Role.Equals(Client, StringComparison.OrdinalIgnoreCase) && (delegatecomputer == null)) { string message = helper.FormatResourceMsgFromResourcetext("CredSSPClientAndDelegateMustBeSpecified", "DelegateComputer", "Role", Client); throw new InvalidOperationException(message); } if (Role.Equals(Client, StringComparison.OrdinalIgnoreCase)) { EnableClientSideSettings(); } if (Role.Equals(Server, StringComparison.OrdinalIgnoreCase)) { EnableServerSideSettings(); } }//End BeginProcessing()
/// <summary> /// Begin processing method. /// </summary> protected override void BeginProcessing() { // If not running elevated, then throw an "elevation required" error message. WSManHelper.ThrowIfNotAdministrator(); if (Role.Equals(Client, StringComparison.OrdinalIgnoreCase)) { DisableClientSideSettings(); } if (Role.Equals(Server, StringComparison.OrdinalIgnoreCase)) { DisableServerSideSettings(); } }
/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { //If not running elevated, then throw an "elevation required" error message. WSManHelper.ThrowIfNotAdministrator(); helper = new WSManHelper(this); String query = helper.GetResourceMsgFromResourcetext("QuickConfigContinueQuery"); String caption = helper.GetResourceMsgFromResourcetext("QuickConfigContinueCaption"); if (!force && !ShouldContinue(query, caption)) { return; } QuickConfigRemoting(true); QuickConfigRemoting(false); }//End BeginProcessing()
protected override void BeginProcessing() { WSManHelper.ThrowIfNotAdministrator(); this.helper = new WSManHelper(this); if (Environment.OSVersion.Version.Major >= 6) { WSManHelper.ThrowIfNotAdministrator(); if (this.delegatecomputer == null || base.Role.Equals("Client", StringComparison.OrdinalIgnoreCase)) { if (!base.Role.Equals("Client", StringComparison.OrdinalIgnoreCase) || this.delegatecomputer != null) { if (base.Role.Equals("Client", StringComparison.OrdinalIgnoreCase)) { this.EnableClientSideSettings(); } if (base.Role.Equals("Server", StringComparison.OrdinalIgnoreCase)) { this.EnableServerSideSettings(); } return; } else { object[] objArray = new object[3]; objArray[0] = "DelegateComputer"; objArray[1] = "Role"; objArray[2] = "Client"; string str = this.helper.FormatResourceMsgFromResourcetext("CredSSPClientAndDelegateMustBeSpecified", objArray); throw new InvalidOperationException(str); } } else { object[] role = new object[4]; role[0] = "DelegateComputer"; role[1] = "Role"; role[2] = base.Role; role[3] = "Client"; string str1 = this.helper.FormatResourceMsgFromResourcetext("CredSSPRoleAndDelegateCannotBeSpecified", role); throw new InvalidOperationException(str1); } } else { string str2 = this.helper.FormatResourceMsgFromResourcetext("CmdletNotAvailable", new object[0]); throw new InvalidOperationException(str2); } }
protected override void BeginProcessing() { WSManHelper.ThrowIfNotAdministrator(); this.helper = new WSManHelper(this); string resourceMsgFromResourcetext = this.helper.GetResourceMsgFromResourcetext("QuickConfigContinueQuery"); string str = this.helper.GetResourceMsgFromResourcetext("QuickConfigContinueCaption"); if (this.force || base.ShouldContinue(resourceMsgFromResourcetext, str)) { this.QuickConfigRemoting(true); this.QuickConfigRemoting(false); return; } else { return; } }
protected override void BeginProcessing() { if (Environment.OSVersion.Version.Major >= 6) { WSManHelper.ThrowIfNotAdministrator(); if (base.Role.Equals("Client", StringComparison.OrdinalIgnoreCase)) { this.DisableClientSideSettings(); } if (base.Role.Equals("Server", StringComparison.OrdinalIgnoreCase)) { this.DisableServerSideSettings(); } return; } else { WSManHelper wSManHelper = new WSManHelper(this); string str = wSManHelper.FormatResourceMsgFromResourcetext("CmdletNotAvailable", new object[0]); throw new InvalidOperationException(str); } }
/// <summary> /// begin processing method. /// </summary> protected override void BeginProcessing() { #if !CORECLR if (Environment.OSVersion.Version.Major < 6) { //OS is XP/Win2k3. Throw error. WSManHelper helper = new WSManHelper(this); string message = helper.FormatResourceMsgFromResourcetext("CmdletNotAvailable"); throw new InvalidOperationException(message); } #endif //If not running elevated, then throw an "elevation required" error message. WSManHelper.ThrowIfNotAdministrator(); if (Role.Equals(Client, StringComparison.OrdinalIgnoreCase)) { DisableClientSideSettings(); } if (Role.Equals(Server, StringComparison.OrdinalIgnoreCase)) { DisableServerSideSettings(); } }//End BeginProcessing()
/// <summary> /// Method to begin processing. /// </summary> protected override void BeginProcessing() { // If not running elevated, then throw an "elevation required" error message. WSManHelper.ThrowIfNotAdministrator(); helper = new WSManHelper(this); IWSManSession m_SessionObj = null; try { IWSManEx wsmanObject = (IWSManEx) new WSManClass(); m_SessionObj = (IWSManSession)wsmanObject.CreateSession(null, 0, null); string result = m_SessionObj.Get(helper.CredSSP_RUri, 0); XmlNode node = helper.GetXmlNode(result, helper.CredSSP_SNode, helper.CredSSP_XMLNmsp); if (node == null) { InvalidOperationException ex = new InvalidOperationException(); ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); WriteError(er); return; } // The application name MUST be "wsman" as wsman got approval from security // folks who suggested to register the SPN with name "wsman". const string applicationname = "wsman"; string credsspResult = GetDelegateSettings(applicationname); if (string.IsNullOrEmpty(credsspResult)) { WriteObject(helper.GetResourceMsgFromResourcetext("NoDelegateFreshCred")); } else { WriteObject(helper.GetResourceMsgFromResourcetext("DelegateFreshCred") + credsspResult); } // Get the server side settings result = m_SessionObj.Get(helper.Service_CredSSP_Uri, 0); node = helper.GetXmlNode(result, helper.CredSSP_SNode, helper.Service_CredSSP_XMLNmsp); if (node == null) { InvalidOperationException ex = new InvalidOperationException(); ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); WriteError(er); return; } if (node.InnerText.Equals("true", StringComparison.OrdinalIgnoreCase)) { WriteObject(helper.GetResourceMsgFromResourcetext("CredSSPServiceConfigured")); } else { WriteObject(helper.GetResourceMsgFromResourcetext("CredSSPServiceNotConfigured")); } } catch (UnauthorizedAccessException ex) { ErrorRecord er = new ErrorRecord(ex, "UnauthorizedAccess", ErrorCategory.PermissionDenied, null); WriteError(er); } catch (SecurityException ex) { ErrorRecord er = new ErrorRecord(ex, "SecurityException", ErrorCategory.InvalidOperation, null); WriteError(er); } catch (ArgumentException ex) { ErrorRecord er = new ErrorRecord(ex, "InvalidArgument", ErrorCategory.InvalidOperation, null); WriteError(er); } catch (System.Xml.XPath.XPathException ex) { ErrorRecord er = new ErrorRecord(ex, "XPathException", ErrorCategory.InvalidOperation, null); WriteError(er); } finally { if (!string.IsNullOrEmpty(m_SessionObj.Error)) { helper.AssertError(m_SessionObj.Error, true, null); } if (m_SessionObj != null) { Dispose(m_SessionObj); } } }
protected override void BeginProcessing() { WSManHelper.ThrowIfNotAdministrator(); this.helper = new WSManHelper(this); if (Environment.OSVersion.Version.Major >= 6) { WSManHelper.ThrowIfNotAdministrator(); IWSManSession wSManSession = null; try { try { IWSManEx wSManClass = (IWSManEx)(new WSManClass()); wSManSession = (IWSManSession)wSManClass.CreateSession(null, 0, null); string str = wSManSession.Get(this.helper.CredSSP_RUri, 0); XmlNode xmlNode = this.helper.GetXmlNode(str, this.helper.CredSSP_SNode, this.helper.CredSSP_XMLNmsp); if (xmlNode != null) { string str1 = "wsman"; string delegateSettings = this.GetDelegateSettings(str1); if (!string.IsNullOrEmpty(delegateSettings)) { base.WriteObject(string.Concat(this.helper.GetResourceMsgFromResourcetext("DelegateFreshCred"), delegateSettings)); } else { base.WriteObject(this.helper.GetResourceMsgFromResourcetext("NoDelegateFreshCred")); } str = wSManSession.Get(this.helper.Service_CredSSP_Uri, 0); xmlNode = this.helper.GetXmlNode(str, this.helper.CredSSP_SNode, this.helper.Service_CredSSP_XMLNmsp); if (xmlNode != null) { if (!xmlNode.InnerText.Equals("true", StringComparison.OrdinalIgnoreCase)) { base.WriteObject(this.helper.GetResourceMsgFromResourcetext("CredSSPServiceNotConfigured")); } else { base.WriteObject(this.helper.GetResourceMsgFromResourcetext("CredSSPServiceConfigured")); } } else { InvalidOperationException invalidOperationException = new InvalidOperationException(); ErrorRecord errorRecord = new ErrorRecord(invalidOperationException, this.helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord); return; } } else { InvalidOperationException invalidOperationException1 = new InvalidOperationException(); ErrorRecord errorRecord1 = new ErrorRecord(invalidOperationException1, this.helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord1); return; } } catch (UnauthorizedAccessException unauthorizedAccessException1) { UnauthorizedAccessException unauthorizedAccessException = unauthorizedAccessException1; ErrorRecord errorRecord2 = new ErrorRecord(unauthorizedAccessException, "UnauthorizedAccess", ErrorCategory.PermissionDenied, null); base.WriteError(errorRecord2); } catch (SecurityException securityException1) { SecurityException securityException = securityException1; ErrorRecord errorRecord3 = new ErrorRecord(securityException, "SecurityException", ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord3); } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; ErrorRecord errorRecord4 = new ErrorRecord(argumentException, "InvalidArgument", ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord4); } catch (XPathException xPathException1) { XPathException xPathException = xPathException1; ErrorRecord errorRecord5 = new ErrorRecord(xPathException, "XPathException", ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord5); } } finally { if (!string.IsNullOrEmpty(wSManSession.Error)) { this.helper.AssertError(wSManSession.Error, true, null); } if (wSManSession != null) { this.Dispose(wSManSession); } } return; } else { string str2 = this.helper.FormatResourceMsgFromResourcetext("CmdletNotAvailable", new object[0]); throw new InvalidOperationException(str2); } }