Skip to content

Commit 72b2bb3

Browse files
authored
Merge pull request #2707 from KoenZomers/AcsConnectToNonExistantSiteError
Added clearer feedback when using ACS to connect to a site that does not exist
2 parents aaef511 + 11a7f93 commit 72b2bb3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Commands/Base/PnPConnection.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ internal static PnPConnection CreateWithACSAppOnly(Uri url, string realm, string
196196
if (realm == null)
197197
{
198198
realm = GetRealmFromTargetUrl(url);
199+
200+
if(realm == null)
201+
{
202+
throw new Exception($"Could not determine realm for the target site '{url}'. Please validate that a site exists at this URL.");
203+
}
199204
}
200205

201206
if (url.DnsSafeHost.Contains("spoppe.com"))
@@ -772,7 +777,7 @@ internal static string GetRealmFromTargetUrl(Uri targetApplicationUri)
772777
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "");
773778

774779
var response = client.GetAsync(targetApplicationUri + "/_vti_bin/client.svc").GetAwaiter().GetResult();
775-
if (response == null)
780+
if (response == null || response.StatusCode == System.Net.HttpStatusCode.NotFound)
776781
{
777782
return null;
778783
}

0 commit comments

Comments
 (0)