public override void ExecuteCmdlet() { base.ExecuteCmdlet(); try { TenantContext.EnsureProperties(tssp => tssp.RootSiteUrl); var TenantUrl = TenantContext.RootSiteUrl.EnsureTrailingSlashLowered(); // Set the Auth Realm for the Tenant Web Context using (var siteWeb = this.ClientContext.Clone(SiteUrl)) { var cq = new ChangeQuery { FetchLimit = 10, Item = true }; var webAuthRealm = siteWeb.Web.GetChanges(cq); siteWeb.Load(webAuthRealm); siteWeb.ExecuteQuery(); } var userPrincipalName = string.Format("{0}|{1}", ClaimIdentifier, this.UserName); DiscoveryGroups.Add(userPrincipalName); try { SetSiteAdmin(SiteUrl, CurrentUserName, true); using (var siteContext = this.ClientContext.Clone(SiteUrl)) { Web _web = siteContext.Web; ProcessSiteCollectionSubWeb(_web, true); var siteProperties = GetSiteProperties(SiteUrl); } } catch (Exception e) { LogError(e, "Failed to processSiteCollection with url {0}", SiteUrl); } finally { //SetSiteAdmin(_siteUrl, CurrentUserName); } } catch (Exception e) { LogError(e, "Failed in SetEveryoneGroup cmdlet {0}", e.Message); } WriteObject(Model); }
/// <summary> /// Queries the collection of groups /// </summary> /// <param name="_principal"></param> /// <returns></returns> private bool IsEveryoneInPrincipal(Principal _principal) { if (DiscoveryGroups.Any(eg => _principal.Title.Equals(eg, StringComparison.CurrentCultureIgnoreCase) || _principal.LoginName.Equals(eg, StringComparison.CurrentCultureIgnoreCase))) { return(true); } return(false); }