public static AADClient Create(string smtpAddress, GraphProxyVersions apiVersion = GraphProxyVersions.Version14) { ArgumentValidator.ThrowIfNullOrEmpty("smtpAddress", smtpAddress); SmtpAddress smtpAddress2 = new SmtpAddress(smtpAddress); if (!smtpAddress2.IsValidAddress) { AADClientFactory.Tracer.TraceDebug <string>(0L, "SMTP address {0} is not valid, cannot create AADClient", smtpAddress); return(null); } OrganizationId organizationId = OrganizationId.FromAcceptedDomain(smtpAddress2.Domain); return(AADClientFactory.Create(organizationId, apiVersion)); }
private static Uri GetRootSiteUrlFromAAD(OrganizationId organizationId) { AADClient aadclient = AADClientFactory.Create(organizationId, GraphProxyVersions.Version14); if (aadclient == null) { SharePointUrl.Tracer.TraceDebug <OrganizationId>(0L, "Failed to create AADClient for organization {0}", organizationId); return(null); } Uri rootSiteUrlFromServiceInfo = SharePointUrl.GetRootSiteUrlFromServiceInfo(aadclient); if (rootSiteUrlFromServiceInfo != null) { SharePointUrl.Tracer.TraceDebug <OrganizationId, Uri>(0L, "Found SharePoint Root Site Url in ServiceInfo for organization {0}: {1}", organizationId, rootSiteUrlFromServiceInfo); } return(rootSiteUrlFromServiceInfo); }