Hi,
The following code is used by me to get organizational services. I know the code looks old. I want to change its authentication type from WS-Trust to Office365 now, but I really don't know any easy way to do it. Does anyone know? I don't think it's possible to just turn OrganizationServiceProxy into IOrganizationService.
public static OrganizationServiceProxy GetOrganizationProxy() { Boolean isConfigExist = ReadConfigurations(); string _serviceApi = string.Empty; string _userName = string.Empty; string _passWord = string.Empty; if (isConfigExist) { config = configurations[0]; _serviceApi = config.OrganizationUri.ToString(); _userName = config.Credentials.UserName.UserName; _passWord = config.Credentials.UserName.Password; } ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(OnRemoteCertificateValidationCallback); Uri endpoint = new Uri(_serviceApi); IServiceManagement serviceManagement = ServiceConfigurationFactory.CreateManagement(endpoint); OrganizationServiceProxy proxy = null; AuthenticationCredentials authCredentials = new AuthenticationCredentials(); authCredentials.ClientCredentials.UserName.UserName = _userName; authCredentials.ClientCredentials.UserName.Password = _passWord; AuthenticationCredentials orgtokenCredentials = serviceManagement.Authenticate(authCredentials); proxy = new ManagedTokenOrganizationServiceProxy(serviceManagement, orgtokenCredentials.SecurityTokenResponse); proxy.EnableProxyTypes(); proxy.Timeout = new TimeSpan(0, 10, 0); return proxy; }
What deployment do you have?
Do you know that there is an easy way to get organization service like mine that can be changed directly instead of using a connection string?
Hello,
I would recommend to use CrmServiceClient to connect to CRM - docs.microsoft.com/.../use-connection-strings-xrm-tooling-connect
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156