protected override void UpdateDataObject() { SPServiceContext context = null; if (ParameterSetName == "UPA") { SPSiteSubscriptionIdentifier subId; if (SiteSubscription != null) { SPSiteSubscription siteSub = SiteSubscription.Read(); subId = siteSub.Id; } else { subId = SPSiteSubscriptionIdentifier.Default; } SPServiceApplication svcApp = UserProfileServiceApplication.Read(); context = SPServiceContext.GetContext(svcApp.ServiceApplicationProxyGroup, subId); } else { using (SPSite site = ContextSite.Read()) { context = SPServiceContext.GetContext(site); } } Common.Audiences.CreateAudience.Create(context, Identity, Description, Membership, Owner, true); }
protected override void InternalProcessRecord() { SPServiceContext context = null; if (ParameterSetName == "UPA") { SPSiteSubscriptionIdentifier subId; if (SiteSubscription != null) { SPSiteSubscription siteSub = SiteSubscription.Read(); subId = siteSub.Id; } else { subId = SPSiteSubscriptionIdentifier.Default; } SPServiceApplication svcApp = UserProfileServiceApplication.Read(); context = SPServiceContext.GetContext(svcApp.ServiceApplicationProxyGroup, subId); } else { using (SPSite site = ContextSite.Read()) { context = SPServiceContext.GetContext(site); } } Common.Audiences.AddAudienceRule.AddRules(context, Identity, Rules.OuterXml, Clear.IsPresent, Compile.IsPresent, GroupExisting.IsPresent, AppendOperator.Value); }
protected override void InternalProcessRecord() { SPServiceContext context = null; if (ParameterSetName == "UPA") { SPSiteSubscriptionIdentifier subId; if (SiteSubscription != null) { SPSiteSubscription siteSub = SiteSubscription.Read(); subId = siteSub.Id; } else { subId = SPSiteSubscriptionIdentifier.Default; } SPServiceApplication svcApp = UserProfileServiceApplication.Read(); context = SPServiceContext.GetContext(svcApp.ServiceApplicationProxyGroup, subId); } else { using (SPSite site = ContextSite.Read()) { context = SPServiceContext.GetContext(site); } } string xml = File.ReadAllText(InputFile); Common.Audiences.ImportAudiences.Import(xml, context, DeleteExisting.IsPresent, Compile.IsPresent, MapFile); }
protected override void UpdateDataObject() { SPServiceContext context = null; UserProfileManager profManager = null; switch (ParameterSetName) { case "Username_UPA": SPSiteSubscriptionIdentifier subId; if (SiteSubscription != null) { SPSiteSubscription siteSub = SiteSubscription.Read(); subId = siteSub.Id; } else { subId = SPSiteSubscriptionIdentifier.Default; } SPServiceApplication svcApp = UserProfileServiceApplication.Read(); context = SPServiceContext.GetContext(svcApp.ServiceApplicationProxyGroup, subId); profManager = new UserProfileManager(context); if (string.IsNullOrEmpty(Username)) { Common.UserProfiles.SetPictureUrl.SetPictures(profManager, Path, Overwrite, IgnoreMissingData, ValidateUrl); } else { Common.UserProfiles.SetPictureUrl.SetPicture(profManager, Username, Path, Overwrite, IgnoreMissingData, ValidateUrl); } break; case "Username_SPSite": using (SPSite site = ContextSite.Read()) { context = SPServiceContext.GetContext(site); } profManager = new UserProfileManager(context); if (string.IsNullOrEmpty(Username)) { Common.UserProfiles.SetPictureUrl.SetPictures(profManager, Path, Overwrite, IgnoreMissingData, ValidateUrl); } else { Common.UserProfiles.SetPictureUrl.SetPicture(profManager, Username, Path, Overwrite, IgnoreMissingData, ValidateUrl); } break; case "UserProfile": Common.UserProfiles.SetPictureUrl.SetPicture(UserProfile, Path, Overwrite, IgnoreMissingData, ValidateUrl); break; } }
protected override IEnumerable <UserProfileChange> RetrieveDataObjects() { SPServiceContext context = null; if (ParameterSetName == "UPA") { SPSiteSubscriptionIdentifier subId; if (SiteSubscription != null) { SPSiteSubscription siteSub = SiteSubscription.Read(); subId = siteSub.Id; } else { subId = SPSiteSubscriptionIdentifier.Default; } SPServiceApplication svcApp = UserProfileServiceApplication.Read(); context = SPServiceContext.GetContext(svcApp.ServiceApplicationProxyGroup, subId); } else { using (SPSite site = ContextSite.Read()) { context = SPServiceContext.GetContext(site); } } UserProfileManager profileManager = new UserProfileManager(context); DateTime tokenStart = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(Interval)); UserProfileChangeToken changeToken = new UserProfileChangeToken(tokenStart); UserProfileChangeQuery changeQuery = new UserProfileChangeQuery(false, true); changeQuery.ChangeTokenStart = changeToken; changeQuery.UserProfile = true; changeQuery.SingleValueProperty = IncludeSingleValuePropertyChanges; changeQuery.MultiValueProperty = IncludeMultiValuePropertyChanges; changeQuery.Anniversary = IncludeAnniversaryChanges; changeQuery.Colleague = IncludeColleagueChanges; changeQuery.OrganizationMembership = IncludeOrganizationMembershipChanges; changeQuery.DistributionListMembership = IncludeDistributionListMembershipChanges; changeQuery.PersonalizationSite = IncludePersonalizationSiteChanges; changeQuery.SiteMembership = IncludeSiteMembershipChanges; UserProfileChangeCollection changes = profileManager.GetChanges(changeQuery); foreach (UserProfileChange change in changes) { WriteResult(change); } return(null); }
protected override IEnumerable <Audience> RetrieveDataObjects() { List <Audience> audiences = new List <Audience>(); SPServiceContext context = null; if (ParameterSetName == "UPA") { SPSiteSubscriptionIdentifier subId; if (SiteSubscription != null) { SPSiteSubscription siteSub = SiteSubscription.Read(); subId = siteSub.Id; } else { subId = SPSiteSubscriptionIdentifier.Default; } SPServiceApplication svcApp = UserProfileServiceApplication.Read(); context = SPServiceContext.GetContext(svcApp.ServiceApplicationProxyGroup, subId); } else { using (SPSite site = ContextSite.Read()) { context = SPServiceContext.GetContext(site); } } AudienceManager manager = new AudienceManager(context); if (!string.IsNullOrEmpty(Identity) && !manager.Audiences.AudienceExist(Identity)) { throw new SPException("Audience name does not exist"); } if (!string.IsNullOrEmpty(Identity)) { audiences.Add(manager.Audiences[Identity]); return(audiences); } foreach (Audience audience in manager.Audiences) { audiences.Add(audience); } return(audiences); }
protected override void InternalProcessRecord() { SPServiceContext context = null; if (ParameterSetName == "UPA") { SPSiteSubscriptionIdentifier subId; if (SiteSubscription != null) { SPSiteSubscription siteSub = SiteSubscription.Read(); subId = siteSub.Id; } else { subId = SPSiteSubscriptionIdentifier.Default; } SPServiceApplication svcApp = UserProfileServiceApplication.Read(); context = SPServiceContext.GetContext(svcApp.ServiceApplicationProxyGroup, subId); } else { using (SPSite site = ContextSite.Read()) { context = SPServiceContext.GetContext(site); } } string xml = Common.Audiences.EnumAudienceRules.EnumRules(context, Identity, Explicit.IsPresent); if (string.IsNullOrEmpty(xml)) { return; } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); WriteResult(xml); }
protected override void InternalValidate() { if (ParameterSetName == "UPA") { SPSiteSubscriptionIdentifier subId; if (SiteSubscription != null) { SPSiteSubscription siteSub = SiteSubscription.Read(); subId = siteSub.Id; } else { subId = SPSiteSubscriptionIdentifier.Default; } SPServiceApplication svcApp = UserProfileServiceApplication.Read(); _context = SPServiceContext.GetContext(svcApp.ServiceApplicationProxyGroup, subId); } else { using (SPSite site = ContextSite.Read()) { _context = SPServiceContext.GetContext(site); } } if (!string.IsNullOrEmpty(Identity)) { base.DataObject = Identity; } if (base.DataObject == null) { base.WriteError(new PSArgumentException("A valid audience name and service application must be provided."), ErrorCategory.InvalidArgument, null); base.SkipProcessCurrentRecord(); } }