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 IEnumerable <AudienceManager> RetrieveDataObjects() { List <AudienceManager> audienceManagers = new List <AudienceManager>(); 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); audienceManagers.Add(manager); return(audienceManagers); }
public SPServiceApplicationProxy CreateProxy(string name, SPServiceApplication serviceApplication, SPServiceProvisioningContext provisioningContext) { if (serviceApplication.GetType() != typeof(NodeServiceApplication)) { throw new NotSupportedException(); } if (serviceApplication == null) { throw new ArgumentNullException("serviceApplication"); } // Verify the service proxy exists. NodeServiceProxy serviceProxy = (NodeServiceProxy)this.Farm.GetObject(name, this.Farm.Id, typeof(NodeServiceProxy)); if (serviceProxy == null) { throw new InvalidOperationException("NodeServiceProxy does not exist in the farm."); } // If the application proxy doesn't exist, create it. NodeServiceApplicationProxy applicationProxy = serviceProxy.ApplicationProxies.GetValue <NodeServiceApplicationProxy>(name); if (applicationProxy == null) { Uri serviceAppAddress = ((NodeServiceApplication)serviceApplication).Uri; applicationProxy = new NodeServiceApplicationProxy(name, serviceProxy, serviceAppAddress); } return(applicationProxy); }
/// <summary> /// Executes the specified command. /// </summary> /// <param name="command">The command.</param> /// <param name="keyValues">The key values.</param> /// <param name="output">The output.</param> /// <returns></returns> public override int Execute(string command, StringDictionary keyValues, out string output) { output = string.Empty; #if !MOSS output = NOT_VALID_FOR_FOUNDATION; return((int)ErrorCodes.GeneralError); #endif SPServiceContext context = null; if (Params["serviceappname"].UserTypedIn) { SPSiteSubscriptionIdentifier subId = Utilities.GetSiteSubscriptionId(new Guid(Params["sitesubscriptionid"].Value)); SPServiceApplication svcApp = Utilities.GetUserProfileServiceApplication(Params["serviceappname"].Value); Utilities.GetServiceContext(svcApp, subId); } else { using (SPSite site = new SPSite(Params["contextsite"].Value)) context = SPServiceContext.GetContext(site); } Console.WriteLine(Common.Audiences.EnumAudienceRules.EnumRules(context, Params["name"].Value, Params["explicit"].UserTypedIn)); return((int)ErrorCodes.NoError); }
public SPServiceApplicationProxy CreateProxy(string name, SPServiceApplication serviceApplication, SPServiceProvisioningContext provisioningContext) { if (serviceApplication.GetType() != typeof(NodeServiceApplication)) { throw new NotSupportedException(); } if (serviceApplication == null) { throw new ArgumentNullException("serviceApplication"); } // Verify the service proxy exists. NodeServiceProxy serviceProxy = (NodeServiceProxy)this.Farm.GetObject(name, this.Farm.Id, typeof(NodeServiceProxy)); if (serviceProxy == null) throw new InvalidOperationException("NodeServiceProxy does not exist in the farm."); // If the application proxy doesn't exist, create it. NodeServiceApplicationProxy applicationProxy = serviceProxy.ApplicationProxies.GetValue<NodeServiceApplicationProxy>(name); if (applicationProxy == null) { Uri serviceAppAddress = ((NodeServiceApplication)serviceApplication).Uri; applicationProxy = new NodeServiceApplicationProxy(name, serviceProxy, serviceAppAddress); } return applicationProxy; }
/// <summary> /// Executes the specified command. /// </summary> /// <param name="command">The command.</param> /// <param name="keyValues">The key values.</param> /// <param name="output">The output.</param> /// <returns></returns> public override int Execute(string command, StringDictionary keyValues, out string output) { output = string.Empty; #if !MOSS output = NOT_VALID_FOR_FOUNDATION; return((int)ErrorCodes.GeneralError); #endif SPServiceContext context = null; if (Params["serviceappname"].UserTypedIn) { SPSiteSubscriptionIdentifier subId = Utilities.GetSiteSubscriptionId(new Guid(Params["sitesubscriptionid"].Value)); SPServiceApplication svcApp = Utilities.GetUserProfileServiceApplication(Params["serviceappname"].Value); Utilities.GetServiceContext(svcApp, subId); } else { using (SPSite site = new SPSite(Params["contextsite"].Value)) context = SPServiceContext.GetContext(site); } Common.Audiences.CreateAudience.Create(context, Params["name"].Value, Params["description"].Value, (RuleEnum)Enum.Parse(typeof(RuleEnum), Params["rule"].Value.ToLowerInvariant(), true), Params["owner"].Value, Params["update"].UserTypedIn); return((int)ErrorCodes.NoError); }
public SPServiceApplicationProxy CreateProxy(string name, bool checkIfExist, SPServiceApplication serviceApplication, SPServiceProvisioningContext provisioningContext) { if (serviceApplication == null) { throw new ArgumentNullException("serviceApplication"); } Type serviceApplicationType = serviceApplication.GetType(); if (serviceApplicationType == null || serviceApplicationType != typeof(ParagoServiceApplication)) { throw new NotSupportedException(); } ParagoServiceProxy serviceProxy = (ParagoServiceProxy)Farm.GetObject(ParagoServiceProxy.DefaultName, Farm.Id, typeof(ParagoServiceProxy)); if (serviceProxy == null) { serviceProxy = new ParagoServiceProxy(Farm); serviceProxy.Update(true); serviceProxy.Provision(); } if (checkIfExist) { ParagoServiceApplicationProxy serviceApplicationProxy = serviceProxy.ApplicationProxies.GetValue <ParagoServiceApplicationProxy>(name); if (serviceApplicationProxy != null) { return(serviceApplicationProxy); } } return(new ParagoServiceApplicationProxy(name, serviceProxy, ((ParagoServiceApplication)serviceApplication).Uri)); }
public SPServiceApplicationProxy CreateProxy(string name, SPServiceApplication serviceApplication, SPServiceProvisioningContext provisioningContext) { if (serviceApplication.GetType() != typeof(BaristaServiceApplication)) { throw new NotSupportedException(); } if (serviceApplication == null) { throw new ArgumentNullException("serviceApplication"); } // verify the service proxy exists var serviceProxy = (BaristaServiceProxy)Farm.GetObject(name, Farm.Id, typeof(BaristaServiceProxy)); if (serviceProxy == null) { throw new InvalidOperationException("BaristaServiceProxy does not exist in the farm."); } // if the app proxy doesn't exist, create it var applicationProxy = serviceProxy.ApplicationProxies.GetValue <BaristaServiceApplicationProxy>(name); if (applicationProxy == null) { var serviceAppAddress = ((BaristaServiceApplication)serviceApplication).Uri; applicationProxy = new BaristaServiceApplicationProxy(name, serviceProxy, serviceAppAddress); } return(applicationProxy); }
/// <summary> /// CreateProxy method override /// </summary> public SPServiceApplicationProxy CreateProxy(string name, SPServiceApplication serviceApplication, SPServiceProvisioningContext provisioningContext) { if (null == serviceApplication) { throw new ArgumentNullException("ServiceApplication"); } if (serviceApplication.GetType() != typeof(IdentityServiceApplication)) { throw new NotSupportedException(); } IdentityServiceProxy serviceProxy = (IdentityServiceProxy)this.Farm.GetObject(string.Empty, this.Farm.Id, typeof(IdentityServiceProxy)); if (null == serviceProxy) { throw new InvalidOperationException("SharePoint.IdentityServiceProxy doesn't exist in the farm"); } ServiceApplicationProxy applicationProxy = serviceProxy.ApplicationProxies.GetValue <ServiceApplicationProxy>(name); if (null == applicationProxy) { applicationProxy = new ServiceApplicationProxy(name, serviceProxy, ((IdentityServiceApplication)serviceApplication).Uri); } return(applicationProxy); }
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; } }
public SPServiceApplicationInstance(ObjectInstance prototype, SPServiceApplication serviceApplication) : this(prototype) { if (serviceApplication == null) { throw new ArgumentNullException("serviceApplication"); } m_serviceApplication = serviceApplication; }
/// <summary> /// InternalProcessRecord method override /// </summary> protected override void InternalProcessRecord() { SPFarm farm = SPFarm.Local; if (null == farm) { ThrowTerminatingError(new InvalidOperationException("SharePoint server farm not found."), ErrorCategory.ResourceUnavailable, this); } IdentityServiceProxy serviceProxy = farm.ServiceProxies.GetValue <IdentityServiceProxy>(); if (null == serviceProxy) { ThrowTerminatingError(new InvalidOperationException("Identity Web Service proxy not found."), ErrorCategory.ResourceUnavailable, this); } ServiceApplicationProxy existingServiceApplicationProxy = serviceProxy.ApplicationProxies.GetValue <ServiceApplicationProxy>(); if (null != existingServiceApplicationProxy) { WriteError(new InvalidOperationException("Identity Web service application proxy exists."), ErrorCategory.ResourceExists, existingServiceApplicationProxy); SkipProcessCurrentRecord(); } Uri serviceApplicationUri = null; if (this.ParameterSetName == UriParameterSetName) { serviceApplicationUri = m_Uri; } else if (this.ParameterSetName == ServiceApplicationParameterSetName) { SPServiceApplication serviceApplication = m_ServiceApplicationPipeBind.Read(); if (null == serviceApplication) { WriteError(new InvalidOperationException("Service application not found."), ErrorCategory.ResourceExists, serviceApplication); SkipProcessCurrentRecord(); } ISharedServiceApplication sharedServiceApplication = serviceApplication as ISharedServiceApplication; if (null == sharedServiceApplication) { WriteError(new InvalidOperationException("Connecting to the specified service application is not supported."), ErrorCategory.ResourceExists, serviceApplication); SkipProcessCurrentRecord(); } serviceApplicationUri = sharedServiceApplication.Uri; } else { ThrowTerminatingError(new InvalidOperationException("Invalid parameter set."), ErrorCategory.InvalidArgument, this); } if ((null != serviceApplicationUri) && (ShouldProcess(this.Name))) { ServiceApplicationProxy serviceApplicationProxy = new ServiceApplicationProxy(this.Name, serviceProxy, serviceApplicationUri); serviceApplicationProxy.Provision(); WriteObject(serviceApplicationProxy); } }
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); }
internal static OutputQueue DisableServiceJobs(SPServiceApplication serviceApp) { var outputQueue = new OutputQueue(); var app = serviceApp as SPIisWebServiceApplication; if (app != null) { if (app.Service != null) { outputQueue.Add(DisableJobs(app.Service)); } } return(outputQueue); }
/// <summary> /// ValidateUniqueName method implementation /// </summary> protected void ValidateUniqueName(object sender, ServerValidateEventArgs e) { ArgumentValidator.IsNotNull(e, "e"); string name = this.txtServiceApplicationName.Text.Trim(); SPServiceApplication applicationByName = Utilities.GetApplicationByName(name); if (this.ServiceApplicationId != Guid.Empty) { e.IsValid = (applicationByName == null || applicationByName.Id == ServiceApplicationId); } else { e.IsValid = (applicationByName == null) || !applicationByName.Name.ToLowerInvariant().Trim().Equals((litServiceApplicationTitle.Text + " (Name)").ToLowerInvariant().Trim()); } }
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); }
/// <summary> /// Runs the specified command. /// </summary> /// <param name="command">The command.</param> /// <param name="keyValues">The key values.</param> /// <param name="output">The output.</param> /// <returns></returns> public override int Execute(string command, StringDictionary keyValues, out string output) { output = string.Empty; #if !MOSS output = NOT_VALID_FOR_FOUNDATION; return((int)ErrorCodes.GeneralError); #endif string username = null; if (Params["username"].UserTypedIn) { username = Params["username"].Value; } string path = Params["path"].Value; SPServiceContext context = null; if (Params["serviceappname"].UserTypedIn) { SPSiteSubscriptionIdentifier subId = Utilities.GetSiteSubscriptionId(new Guid(Params["sitesubscriptionid"].Value)); SPServiceApplication svcApp = Utilities.GetUserProfileServiceApplication(Params["serviceappname"].Value); Utilities.GetServiceContext(svcApp, subId); } else { using (SPSite site = new SPSite(Params["contextsite"].Value)) context = SPServiceContext.GetContext(site); } bool overwrite = Params["overwrite"].UserTypedIn; bool ignoreMissingData = Params["ignoremissingdata"].UserTypedIn; bool validateUrl = Params["validateurl"].UserTypedIn; UserProfileManager 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); } return((int)ErrorCodes.NoError); }
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); }
/// <summary> /// Executes the specified command. /// </summary> /// <param name="command">The command.</param> /// <param name="keyValues">The key values.</param> /// <param name="output">The output.</param> /// <returns></returns> public override int Execute(string command, StringDictionary keyValues, out string output) { output = string.Empty; #if !MOSS output = NOT_VALID_FOR_FOUNDATION; return((int)ErrorCodes.GeneralError); #endif string rules; if (Params["rules"].UserTypedIn) { rules = Params["rules"].Value; } else { rules = File.ReadAllText(Params["rulesfile"].Value); } SPServiceContext context = null; if (Params["serviceappname"].UserTypedIn) { SPSiteSubscriptionIdentifier subId = Utilities.GetSiteSubscriptionId(new Guid(Params["sitesubscriptionid"].Value)); SPServiceApplication svcApp = Utilities.GetUserProfileServiceApplication(Params["serviceappname"].Value); Utilities.GetServiceContext(svcApp, subId); } else { using (SPSite site = new SPSite(Params["contextsite"].Value)) context = SPServiceContext.GetContext(site); } Common.Audiences.AddAudienceRule.AddRules(context, Params["name"].Value, rules, Params["clear"].UserTypedIn, Params["compile"].UserTypedIn, Params["groupexisting"].UserTypedIn, (AppendOp)Enum.Parse(typeof(AppendOp), Params["appendop"].Value, true)); return((int)ErrorCodes.NoError); }
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(); } }
/// <summary> /// Validate the arguments. /// </summary> protected override void InternalValidate() { // Validate a farm exists SPFarm farm = SPFarm.Local; if (farm == null) { this.ThrowTerminatingError(new InvalidOperationException("SharePoint server farm not found."), ErrorCategory.InvalidOperation, this); } SPServer server = SPServer.Local; if (server == null) { this.ThrowTerminatingError(new InvalidOperationException("SharePoint local server not found."), ErrorCategory.InvalidOperation, this); } // Get the service ClubCloudService service = SPFarm.Local.Services.GetValue <ClubCloudService>(); if (service != null) { // Check for duplicate name SPServiceApplication application = service.Applications[this.Name]; if (application != null) { this.ThrowTerminatingError(new InvalidOperationException("A service application with that name already exists."), ErrorCategory.InvalidOperation, this); } } if (string.IsNullOrEmpty(this.DatabaseServerName)) { this.DatabaseServerName = SPWebService.ContentService.DefaultDatabaseInstance.NormalizedDataSource; } }
/// <summary> /// Executes the specified command. /// </summary> /// <param name="command">The command.</param> /// <param name="keyValues">The key values.</param> /// <param name="output">The output.</param> /// <returns></returns> public override int Execute(string command, StringDictionary keyValues, out string output) { output = string.Empty; #if !MOSS output = NOT_VALID_FOR_FOUNDATION; return((int)ErrorCodes.GeneralError); #endif string inputFile = Params["inputfile"].Value; bool deleteExisting = Params["deleteexisting"].UserTypedIn; bool compile = Params["compile"].UserTypedIn; string mapFile = default(string); if (Params["mapfile"].UserTypedIn) { mapFile = Params["mapfile"].Value; } string xml = File.ReadAllText(inputFile); SPServiceContext context = null; if (Params["serviceappname"].UserTypedIn) { SPSiteSubscriptionIdentifier subId = Utilities.GetSiteSubscriptionId(new Guid(Params["sitesubscriptionid"].Value)); SPServiceApplication svcApp = Utilities.GetUserProfileServiceApplication(Params["serviceappname"].Value); Utilities.GetServiceContext(svcApp, subId); } else { using (SPSite site = new SPSite(Params["contextsite"].Value)) context = SPServiceContext.GetContext(site); } Common.Audiences.ImportAudiences.Import(xml, context, deleteExisting, compile, mapFile); return((int)ErrorCodes.NoError); }
/// <summary> /// This method gets invoked when the command is called /// </summary> protected override void InternalProcessRecord() { SPServiceApplication resolvedApplication = null; ClubCloudServiceApplication castedApplication = null; resolvedApplication = this.Identity.Read(); if (resolvedApplication == null) { this.ThrowTerminatingError(new InvalidOperationException("No service application was found."), ErrorCategory.InvalidOperation, this); } castedApplication = resolvedApplication as ClubCloudServiceApplication; if (castedApplication == null) { this.ThrowTerminatingError(new InvalidOperationException("The service application provided was not of the correct type."), ErrorCategory.InvalidOperation, this); } if (this.ShouldProcess(castedApplication.Name)) { // Update the name if (!string.IsNullOrEmpty(this.Name) && (!string.Equals(this.Name.Trim(), castedApplication.Name, StringComparison.OrdinalIgnoreCase))) { // Get the service ClubCloudService service = SPFarm.Local.Services.GetValue <ClubCloudService>(); if (service != null) { // Check for duplicate name SPServiceApplication duplicateApplication = service.Applications[this.Name.Trim()]; if (duplicateApplication != null) { this.ThrowTerminatingError(new InvalidOperationException("A service application with that name already exists."), ErrorCategory.InvalidOperation, this); } } castedApplication.Name = this.Name.Trim(); } // Update the application pool if (this.ApplicationPool != null) { SPIisWebServiceApplicationPool resolvedApplicationPool = this.ApplicationPool.Read(); if (resolvedApplicationPool != null) { castedApplication.ApplicationPool = resolvedApplicationPool; } } if (this.DatabaseCredentials != null) { NetworkCredential databaseCredentials = (NetworkCredential)this.DatabaseCredentials; castedApplication.Database.Username = databaseCredentials.UserName; castedApplication.Database.Password = databaseCredentials.Password; } else if (!string.IsNullOrEmpty(castedApplication.Database.Username)) { castedApplication.Database.Username = null; castedApplication.Database.Password = null; } if (!string.IsNullOrEmpty(this.DatabaseFailoverServerName)) { castedApplication.Database.AddFailoverServiceInstance(this.DatabaseFailoverServerName); } else if (castedApplication.Database.FailoverServer != null) { castedApplication.Database.AddFailoverServiceInstance(null); } castedApplication.Database.Update(); castedApplication.Update(); } }
/// <summary> /// Adds the rules. /// </summary> /// <param name="context">The context.</param> /// <param name="audienceName">Name of the audience.</param> /// <param name="rules">The rules.</param> /// <param name="clearExistingRules">if set to <c>true</c> [clear existing rules].</param> /// <param name="compile">if set to <c>true</c> [compile].</param> /// <param name="groupExisting">if set to <c>true</c> [group existing].</param> /// <param name="appendOp">The append op.</param> /// <returns></returns> internal static ArrayList AddRules(SPServiceContext context, string audienceName, string rules, bool clearExistingRules, bool compile, bool groupExisting, AppendOp appendOp) { AudienceManager manager = new AudienceManager(context); if (!manager.Audiences.AudienceExist(audienceName)) { throw new SPException("Audience name does not exist"); } Audience audience = manager.Audiences[audienceName]; /* * Operator Need left and right operands (not a group operator) * = Yes * > Yes * >= Yes * < Yes * <= Yes * Contains Yes * Reports Under Yes (Left operand must be 'Everyone') * <> Yes * Not contains Yes * AND No * OR No * ( No * ) No * Member Of Yes (Left operand must be 'DL') */ XmlDocument rulesDoc = new XmlDocument(); rulesDoc.LoadXml(rules); ArrayList audienceRules = audience.AudienceRules; bool ruleListNotEmpty = false; if (audienceRules == null || clearExistingRules) { audienceRules = new ArrayList(); } else { ruleListNotEmpty = true; } //if the rule is not emply, start with a group operator 'AND' to append if (ruleListNotEmpty) { if (groupExisting) { audienceRules.Insert(0, new AudienceRuleComponent(null, "(", null)); audienceRules.Add(new AudienceRuleComponent(null, ")", null)); } audienceRules.Add(new AudienceRuleComponent(null, appendOp.ToString(), null)); } if (rulesDoc.SelectNodes("//rule") == null || rulesDoc.SelectNodes("//rule").Count == 0) { throw new ArgumentException("No rules were supplied."); } foreach (XmlElement rule in rulesDoc.SelectNodes("//rule")) { string op = rule.GetAttribute("op").ToLowerInvariant(); string field = null; string val = null; bool valIsRequired = true; bool fieldIsRequired = false; switch (op) { case "=": case ">": case ">=": case "<": case "<=": case "contains": case "<>": case "not contains": field = rule.GetAttribute("field"); val = rule.GetAttribute("value"); fieldIsRequired = true; break; case "reports under": field = "Everyone"; val = rule.GetAttribute("value"); break; case "member of": field = "DL"; val = rule.GetAttribute("value"); break; case "and": case "or": case "(": case ")": valIsRequired = false; break; default: throw new ArgumentException(string.Format("Rule operator is invalid: {0}", rule.GetAttribute("op"))); } if (valIsRequired && string.IsNullOrEmpty(val)) { throw new ArgumentNullException(string.Format("Rule value attribute is missing or invalid: {0}", rule.GetAttribute("value"))); } if (fieldIsRequired && string.IsNullOrEmpty(field)) { throw new ArgumentNullException(string.Format("Rule field attribute is missing or invalid: {0}", rule.GetAttribute("field"))); } AudienceRuleComponent r0 = new AudienceRuleComponent(field, op, val); audienceRules.Add(r0); } audience.AudienceRules = audienceRules; audience.Commit(); if (compile) { SPServiceApplication svcApp = Utilities.GetUserProfileServiceApplication(context); if (svcApp != null) { CompileAudience(svcApp.Id, audience.AudienceName); } } return(audienceRules); }
/// <summary> /// This method gets invoked when the command is called /// </summary> protected override void InternalProcessRecord() { Uri applicationUri = null; SPServiceApplication resolvedApplication = null; ClubCloudServiceApplication castedApplication = null; if (this.ServiceApplication == null && string.IsNullOrEmpty(this.Uri)) { this.ThrowTerminatingError(new InvalidOperationException("No service application or Uri was provided."), ErrorCategory.InvalidOperation, this); } if (this.ServiceApplication != null) { resolvedApplication = this.ServiceApplication.Read(); if (resolvedApplication == null) { this.ThrowTerminatingError(new InvalidOperationException("Service application not found."), ErrorCategory.InvalidOperation, this); } castedApplication = resolvedApplication as ClubCloudServiceApplication; if (castedApplication == null) { this.ThrowTerminatingError(new InvalidOperationException("Service application was not of the correct type."), ErrorCategory.InvalidOperation, this); } applicationUri = castedApplication.Uri; if (string.IsNullOrEmpty(this.Name)) { this.Name = castedApplication.Name + " Proxy"; } } else { applicationUri = new Uri(this.Uri); } if (this.ShouldProcess(this.Name)) { // Ensure the service exists ClubCloudService.GetOrCreateService(); // Ensure the proxy exists ClubCloudServiceProxy serviceProxy = ClubCloudServiceProxy.GetOrCreateServiceProxy(); // Create the service application proxy ClubCloudServiceApplicationProxy proxy = new ClubCloudServiceApplicationProxy(this.Name, serviceProxy, applicationUri); proxy.Update(); proxy.Provision(); if (this.DefaultProxyGroup.ToBool()) { SPServiceApplicationProxyGroup group = SPServiceApplicationProxyGroup.Default; group.Add(proxy); group.Update(); } this.WriteObject(proxy); } }
protected override void InternalProcessRecord() { #region validation stuff // ensure can hit farm SPFarm farm = SPFarm.Local; if (farm == null) { ThrowTerminatingError(new InvalidOperationException("SharePoint farm not found."), ErrorCategory.ResourceUnavailable, this); SkipProcessCurrentRecord(); } // ensure proxy installed CalcServiceProxy serviceProxy = farm.ServiceProxies.GetValue <CalcServiceProxy>(); if (serviceProxy == null) { ThrowTerminatingError(new InvalidOperationException("Wingtip Calc Service Proxy not found (likely not installed)."), ErrorCategory.NotInstalled, this); SkipProcessCurrentRecord(); } // ensure can hit service application CalcServiceApplicationProxy existingServiceAppProxy = serviceProxy.ApplicationProxies.GetValue <CalcServiceApplicationProxy>(); if (existingServiceAppProxy != null) { ThrowTerminatingError(new InvalidOperationException("Wingtip Calc Service Application Proxy already exists."), ErrorCategory.ResourceExists, this); SkipProcessCurrentRecord(); } #endregion Uri serviceApplicationAddress = null; if (ParameterSetName == "Uri") { serviceApplicationAddress = _uri; } else if (ParameterSetName == "ServiceApplication") { // make sure can get a refernce to service app SPServiceApplication serviceApp = ServiceApplication.Read(); if (serviceApp == null) { WriteError(new InvalidOperationException("Service application not found."), ErrorCategory.ResourceExists, serviceApp); SkipProcessCurrentRecord(); } // make sure can connect to service app ISharedServiceApplication sharedServiceApp = serviceApp as ISharedServiceApplication; if (sharedServiceApp == null) { WriteError(new InvalidOperationException("Service application not found."), ErrorCategory.ResourceExists, serviceApp); SkipProcessCurrentRecord(); } serviceApplicationAddress = sharedServiceApp.Uri; } else { ThrowTerminatingError(new InvalidOperationException("Invalid parameter set."), ErrorCategory.InvalidArgument, this); } // create the service app proxy if ((serviceApplicationAddress != null) && ShouldProcess(this.Name)) { CalcServiceApplicationProxy serviceAppProxy = new CalcServiceApplicationProxy( this.Name, serviceProxy, serviceApplicationAddress); // provision the service app proxy serviceAppProxy.Provision(); // pass service app proxy back to the PowerShell WriteObject(serviceAppProxy); } }
public SPServiceApplicationProxy CreateProxy(string name, SPServiceApplication serviceApplication, SPServiceProvisioningContext provisioningContext) { throw new NotImplementedException(); }
public SPServiceApplicationEntity(SPServiceApplication s) { _underlyingObject = s; }
public SPServiceApplicationProxy CreateProxy(string name, SPServiceApplication serviceApplication, SPServiceProvisioningContext provisioningContext) { return(CreateProxy(name, true, serviceApplication, provisioningContext)); }