/// <summary> /// Adds a new Exchange service account /// </summary> /// <param name="pConnectionServer"> /// The Connection server to add the service to /// </param> /// <param name="pDisplayName"> /// Name of the service to add. Display name should be unique among external services. /// </param> /// <param name="pServiceAlias"></param> /// <param name="pServicePassword"></param> /// <param name="pServerName"></param> /// <param name="pAuthenticationMode"></param> /// <param name="pExchangeServerType"></param> /// <param name="pSecurityTransportType"></param> /// <param name="oNewSerive"></param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult AddExchangeExternalService(ConnectionServerRest pConnectionServer, string pDisplayName, string pServiceAlias, string pServicePassword, string pServerName, AuthenticationMode pAuthenticationMode, ExchServerType pExchangeServerType, SecurityTransportType pSecurityTransportType, out ExternalService oNewSerive) { oNewSerive = null; var res = AddExchangeExternalService(pConnectionServer, pDisplayName, pServiceAlias, pServicePassword, pServerName, pAuthenticationMode, pExchangeServerType, pSecurityTransportType); if (res.Success) { return(GetExternalService(out oNewSerive, pConnectionServer, res.ReturnedObjectId)); } return(res); }
/// <summary> /// Adds a new Exchange service account /// </summary> /// <param name="pConnectionServer"> /// The Connection server to add the service to /// </param> /// <param name="pDisplayName"> /// Name of the service to add. Display name should be unique among external services. /// </param> /// <param name="pServiceAlias"></param> /// <param name="pServicePassword"></param> /// <param name="pServerName"></param> /// <param name="pAuthenticationMode"></param> /// <param name="pExchangeServerType"></param> /// <param name="pSecurityTransportType"></param> /// <returns> /// Instance of the WebCallResults class containing details of the items sent and recieved from the CUPI interface. /// </returns> public static WebCallResult AddExchangeExternalService(ConnectionServerRest pConnectionServer, string pDisplayName, string pServiceAlias, string pServicePassword, string pServerName, AuthenticationMode pAuthenticationMode, ExchServerType pExchangeServerType, SecurityTransportType pSecurityTransportType) { WebCallResult res = new WebCallResult { Success = false }; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to AddExchangeExternalService"; return(res); } //make sure that something is passed in for the required param if (String.IsNullOrEmpty(pDisplayName)) { res.ErrorText = "Empty value passed for display name in AddExchangeExternalService"; return(res); } string strBody = "<ExternalService>"; strBody += string.Format("<{0}>{1}</{0}>", "DisplayName", pDisplayName.HtmlBodySafe()); strBody += string.Format("<{0}>{1}</{0}>", "ServiceAlias", pServiceAlias.HtmlBodySafe()); strBody += string.Format("<{0}>{1}</{0}>", "ServicePassword", pServicePassword.HtmlBodySafe()); strBody += string.Format("<{0}>{1}</{0}>", "ServerType", (int)ServerType.Exchange); strBody += string.Format("<{0}>{1}</{0}>", "Server", pServerName); strBody += string.Format("<{0}>{1}</{0}>", "AuthenticationMode", (int)pAuthenticationMode); strBody += string.Format("<{0}>{1}</{0}>", "ExchServerType", (int)pExchangeServerType); strBody += string.Format("<{0}>{1}</{0}>", "SecurityTransportType", (int)pSecurityTransportType); strBody += "</ExternalService>"; res = pConnectionServer.GetCupiResponse(string.Format("{0}externalservices", pConnectionServer.BaseUrl), MethodType.POST, strBody, false); //if the call went through then the ObjectId will be returned in the URI form. if (res.Success) { const string strPrefix = @"/vmrest/externalservices/"; if (res.ResponseText.Contains(strPrefix)) { res.ReturnedObjectId = res.ResponseText.Replace(strPrefix, "").Trim(); } } return(res); }