Problem:
When trying to populate audiences nothing happens. Errors are logged into application event log:
5693: Failed to compile audience. Exception was: 'Failed to obtain crawl status.'
and
10016: The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
{3D42CCB1-4665-4620-92A3-478F47389230}
to the user DOMAIN\USERACCOUNT SID (S-1-5-21-2339047900-2053458781-3908873488-1605). This security permission can be modified using the Component Services administrative tool.
Solution:
The tricky part was that when looking at the DCOM Config list, there are no items with the GUID {3D42CCB1-4665-4620-92A3-478F47389230}. However, doing a search on the registry revealed that the problematic item was OSearch.
So, in Component Services, give Local Activation permission on the OSearch application to the account that is used as your SSP Service Credentials (Central Administration > Application Management > Manage this Farm's Shared Services > New Shared Services Provider).
Note! If SSP Service Credentials account is different from the account mentioned in the error message, the reasons for the error message is probably slightly different, so give permissions to the user mentioned in the error message.
Showing posts with label audience. Show all posts
Showing posts with label audience. Show all posts
October 30, 2007
August 24, 2007
MOSS: All web parts appear as ErrorWebPart
Problem:
When trying to enumerate web parts on a site all web parts appear as ErrorWebPart. There are OOB and custom web parts on the site.
In my case I have a Web Service that is used to create new MOSS sites. At some stage I need to define the Audience setting of some web parts and it has to be done programmatically. As far as I know, Audience settings cannot be set in Site Definitions. Please let me know if it is possible.
Solution:
Put all custom web parts in GAC. It appears that if even one custom web part has problems with permissions (not in GAC or otherwise not trusted), all web parts appear as ErrorWebPart.
When trying to enumerate web parts on a site all web parts appear as ErrorWebPart. There are OOB and custom web parts on the site.
In my case I have a Web Service that is used to create new MOSS sites. At some stage I need to define the Audience setting of some web parts and it has to be done programmatically. As far as I know, Audience settings cannot be set in Site Definitions. Please let me know if it is possible.
Solution:
Put all custom web parts in GAC. It appears that if even one custom web part has problems with permissions (not in GAC or otherwise not trusted), all web parts appear as ErrorWebPart.
May 2, 2007
MOSS: How to hide UI elements according to user's Audience
Problem:
I need to hide different UI elements from the master page depending on the current user's audience. SPSecurityTrimmedControl apparently knows nothing about audiences so it cannot be used.
Solution:
Changing master pages on the fly is possible, as described here, but if you'd just want to hide some specific things without making whole lotta master pages this custom control might come handy.
Create Web Custom Control with VS 2005 and add this code:
Then register the custom control on your chosen master page:
And finally just surround the control(s) you wish to control with the tags like below. This shows the search functionality only for users in the audience "External users":
The custom control inherits from SPSecurityTrimmedControl so you could possibly (haven't tested) use some functionality of that control too. It's not necessary to inherit it from SPSecurityTrimmedControl, of course, you could just inherit from WebControl if you're only interested in the Audience functionality.
I need to hide different UI elements from the master page depending on the current user's audience. SPSecurityTrimmedControl apparently knows nothing about audiences so it cannot be used.
Solution:
Changing master pages on the fly is possible, as described here, but if you'd just want to hide some specific things without making whole lotta master pages this custom control might come handy.
Create Web Custom Control with VS 2005 and add this code:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Text;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Microsoft.SharePoint.WebControls;using Microsoft.SharePoint;using Microsoft.Office.Server.Audience;using Microsoft.Office.Server;using System.Collections;namespace HamarData.WebControls{[DefaultProperty("Text")]
public class AudienceControl : SPSecurityTrimmedControl
{private List<string> _audiences = new List<string>();
[DefaultValue(""), Category("Behavior")]
public string AudiencesString
{ get {return string.Join(",", _audiences.ToArray());
}
set {_audiences.AddRange(value.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries));
}
}
protected override void Render(HtmlTextWriter output)
{ if (!string.IsNullOrEmpty(AudiencesString) && CheckAudience()) { base.Render(output);}
}
///
/// Checks if the user belongs to an audience that is allowed to view the content.
///
///True if user is allowed to see the content, otherwise false.
private bool CheckAudience()
{bool retVal = false;
try {SPSite site = SPControl.GetContextSite(HttpContext.Current);
ServerContext context = ServerContext.GetContext(site);
AudienceManager AudMgr = new AudienceManager(context);
SPWeb web = SPControl.GetContextWeb(HttpContext.Current);
try {ArrayList audienceIDNames = AudMgr.GetUserAudienceIDs(HttpContext.Current.User.Identity.Name, true, web);
for(int i = 0; i < audienceIDNames.Count; i++)
{
if(_audiences.Contains(((AudienceNameID)audienceIDNames[i]).AudienceName))
{ retVal = true; break;}
}
}
catch(AudienceException)
{ //Your exception handling code here}
}
catch(Exception)
{}
return retVal;}
}
}
Then register the custom control on your chosen master page:
<%@ Register TagPrefix="HamarData" Namespace="HamarData.WebControls"
Assembly="AudienceControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=90342589787ab5be" %>
And finally just surround the control(s) you wish to control with the
<HamarData:AudienceControl AudiencesString="External users" runat="server">
<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox"/>
</asp:ContentPlaceHolder>
</HamarData:AudienceControl>
The custom control inherits from SPSecurityTrimmedControl so you could possibly (haven't tested) use some functionality of that control too. It's not necessary to inherit it from SPSecurityTrimmedControl, of course, you could just inherit from WebControl if you're only interested in the Audience functionality.
Subscribe to:
Posts (Atom)