Hi, I am trying to connect to the Dynamics organizationservice via single sign on to Azure AD. I cannot find any code sample that works without providing username AND password. We created an App Registration in Azure AD and use it in the code below.
This is the code that should work, but it doesn't connect.
Can anybody help?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim region As String = String.Empty
Dim orgName As String = String.Empty
Dim isOnPrem As Boolean = False
Dim originalUrl As String = "do.api.crm4.dynamics.com/.../organization.svc"
Utilities.GetOrgnameAndOnlineRegionFromServiceUri(New Uri(originalUrl), region, orgName, isOnPrem)
Dim path As String = IO.Path.Combine(IO.Path.GetTempPath(), "oauth-cache.txt")
Dim crmSvc = New CrmServiceClient(CrmUserId, CrmServiceClient.MakeSecureString(crmPassword),
region,
orgName,
False,
Nothing,
Nothing,
"74c5e5c9-52db-4cee-54cb-e213e8f223ea",
New Uri("http://crm.company.nl"),
path, Nothing, Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior.Auto)
'' crmSvc.isReady is FALSE.
crmSvc = New CrmServiceClient(CrmUserId, CrmServiceClient.MakeSecureString(crmPassword),
region,
orgName,
True,
True,
Nothing,
True)
'' crmSvc.isReady is TRUE.
MessageBox.Show(crmSvc.IsReady.ToString())
End Sub