Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Change WS-Trust security protocol to Office 365 authentication

Posted on by 386

Hello,

I got an email about "D365 Platform Modernization: Deprecate legacy authentication-WS-Trust" last week. I compared my code with the one mentioned in that email about how to determine that my code is using WS-trust, I found that I was using the OrganizationServiceProxy class,It belongs to ws-trust.

I found an article published in 2019 on the official website about how to use CrmServiceClient to connect to organizational services. Please see the following code. But I feel like this code also belongs to ws-trust, not Office 365.

I just want to make sure that the way I connect to the organization service given in the following code belongs to wstrust, and if it still belongs to ws-trust, if I want to change it based on the code in it, how do I need to change this code to change my security protocol from ws-trust to office 365?

static void Main(string[] args)
{            
    // e.g. https://yourorg.crm.dynamics.com
    string url = "";
    // e.g. you@yourorg.onmicrosoft.com
    string userName = "";
    // e.g. y0urp455w0rd 
    string password = "";

    string conn = $@"
    Url = {url};
    AuthType = Office365;
    UserName = {userName};
    Password = {password};
    RequireNewInstance = True";

    using (var svc = new CrmServiceClient(conn))
    {

        WhoAmIRequest request = new WhoAmIRequest();

        WhoAmIResponse response = (WhoAmIResponse)svc.Execute(request);

        Console.WriteLine("Your UserId is {0}", response.UserId);

        Console.WriteLine("Press any key to exit.");
        Console.ReadLine();
    }
}

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans