Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6602231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:51:07+00:00 2026-05-25T18:51:07+00:00

I have a Silverlight control in MOSS (Sharepoint 2007) which I want to conditionally

  • 0

I have a Silverlight control in MOSS (Sharepoint 2007) which I want to conditionally enable based upon the user roles set in Sharepoint. I found that I may add a Web reference to the UserGroups service with

http://<server-url>/_vti_bin/usergroup.asmx

according to this article on MSDN. To my chagrin, although I can easily add a Web reference, I have not been able to find what assembly I must reference. Does anyone know what assembly this, and whether I may going the correct route? Thanks always.

Edit
Silverlight is client side so apparently I need a way to get the SPUser and SPGroup information from the server. WSS services dont’ seem to have a useful method. I’m now trying to make a page in Sharepoint Designer and use it as a quasi RESTful service. Is this folly? I would expect Sharepoint to come with this particular service.

Edit
Since SharePoint 2007 doesn’t allow Silverlight Controls to access server side API elements like SPUser, I came up with a solution where I pass flag values in the InitParameters. It is posted below.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:51:08+00:00Added an answer on May 25, 2026 at 6:51 pm

    I found that MOSS (a.k.a. SharePoint 2007) has no mechanism for accessing SPUser permission the client. Hence SilverLight controls have no direct means to obtain this information. My solution was to modify the WebPart hosting the SilverLight control to include a property, which would pass that information to the SilverLight control as one of the InitParams.

    Currently there are many WebParts for hosting a SilverLight control available on the Web. Here are a few examples.

    CodePlex
    http://silverlightwebpart.codeplex.com/

    Kirk Evans Blog
    http://blogs.msdn.com/b/kaevans/archive/2008/10/08/hosting-silverlight-in-a-sharepoint-webpart.aspx

    There are noticable similarities with my WebPart and the one in this article.
    http://blogs.msdn.com/b/andreww/archive/2009/03/12/silverlight-web-part-in-sharepoint.aspx

    What I decided to do is make the WebPart itself configurable

    public class SecureSilverLightWebPart : Microsoft.SharePoint.WebPartPages.WebPart
    {
        private int _controlWidth;
        [Personalizable(PersonalizationScope.Shared), WebBrowsable(true),
        WebDisplayName("Silverlight Control Width")]
        public int ControlWidth
        {
            get { return _controlWidth; }
            set { _controlWidth = value; }
        }
        private int _controlHeight;
        [Personalizable(PersonalizationScope.Shared), WebBrowsable(true), WebDisplayName("Silverlight Control Height")]
        public int ControlHeight
        {
            get { return _controlHeight; }
            set { _controlHeight = value; }
        }
    
        string _silverLightXapPath = string.Empty;
        [Personalizable(PersonalizationScope.Shared), WebBrowsable(true), WebDisplayName("SilverLight Xap file path"),
       WebDescription("Enter the SilverLight Xap File Name which will be downloaded at Runtime")]
        public string SilverLightXapPath
        {
            get { return _silverLightXapPath; }
            set { _silverLightXapPath = value; }
        }
    
        string _controlParameters = "";
        [Personalizable(PersonalizationScope.Shared), WebBrowsable(true), WebDisplayName("Parameters to SilverLight Application"),
       WebDescription("Enter Key Value Pair Parameters That Needs to be sent to SilverLight Application")]
        public string ControlParameters
        {
            get { return _controlParameters; }
            set { _controlParameters = value; }
        }
    
        private string _fullAccessGroup = "";
        [Personalizable(PersonalizationScope.Shared), WebBrowsable(true),
         WebDisplayName("Group membership required to enable Silverlight Application"),
         WebDescription("Enter the Sharepoint group required to enable this component.")]
        public string FullAccessGroup
        {
            get { return _fullAccessGroup; }
            set { _fullAccessGroup = value; }
        }
    
        // This method member checks whether the current
        // SharePoint user is a member of the group, groupName
        private bool IsMember(string groupName)
        {
            bool isMember;
            SPSite site = SPContext.Current.Web.Site;
            SPWeb web = site.OpenWeb();
            try
            {
                isMember = web.IsCurrentUserMemberOfGroup(web.Groups[groupName].ID);
            }
            catch (SPException ex)
            {
                isMember = false;
            }
            finally
            {
                web.Close();
                site.Close();
            }
    
            return isMember;
        }
    
    
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
    
            if (_controlHeight != 0 && _controlWidth != 0 && _silverLightXapPath != string.Empty)
            {
                Silverlight sl = new Silverlight();
    
                sl.ID = "SlCoffee";
    
                if (ConfigurationSettings.AppSettings != null)
                {
                    //In the Web.config for the Sharepoint site I have a key in the AppSettings
                    //pointing to the where the Xap files are saved. Something
                    //like <add key="SITEURL" value="http://MyServer:43746/XapFiles/" />
                    if (ConfigurationSettings.AppSettings["SITEURL"] != string.Empty)
                    {
                        string url = ConfigurationSettings.AppSettings["SITEURL"];
                        sl.Source = url + _silverLightXapPath;
                    }
                }
    
                sl.Width = new Unit(_controlWidth);
    
                sl.Windowless = true;
    
                sl.Height = new Unit(_controlHeight);
    
    
                int SettingCount = ConfigurationSettings.AppSettings.Count;
                StringBuilder SB = new StringBuilder();
    
                //Optional
                for (int index = 0; index < SettingCount; index++)
                {
                    //Most of the InitParams are kept in the AppSettings. You probably
                    //wouldn't send all of your AppSettings to the control like this.
                    if (ConfigurationSettings.AppSettings.GetKey(index).StartsWith("client"))
                    {
                        SB.Append(ConfigurationSettings.AppSettings.GetKey(index));
                        SB.Append("=");
                        SB.Append(ConfigurationSettings.AppSettings[index]);
                        SB.Append(",");
                    }
                }
    
                //This is the place in the code where SPUser and Group information is
                //sent to the SilverLight control hosted by this WebPart.
                SB.Append("UserId=" + SPContext.Current.Web.CurrentUser + ",");
                SB.Append(_controlParameters);
    
                //Security portion
                SB.Append("FullControl=" + IsMember(FullAccessGroup));
    
                sl.InitParameters = SB.ToString();
    
                Controls.Add(sl);
            }
    
        }
    
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
    
            ScriptManager sm = ScriptManager.GetCurrent(Page);
    
            if (sm == null)
            {
                sm = new ScriptManager();
                Controls.AddAt(0, sm);
            }
        }
    
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
            if (_controlHeight == 0 || _controlWidth == 0 || _silverLightXapPath == string.Empty)
            {
                writer.Write("<h3>Please Configure Web Part Properties<h3>");
            }
        }
    }
    

    Next in the SilverLight control I use the Initparameters

    /// <summary>
    /// Handles the Loaded event of the MainPage control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        if(UserMayEdit() )
        {
            // User is a member of the group set up in configuration of the WebPart.
            // enable any controls accordingly.
            TabItem_Backlog.IsEnabled = true;
        }
        else
        {
            // User is not a member - disable.
            TabItem_Backlog.IsEnabled = false;
            TabItem_Approved.IsSelected = true;
        }
    
        //...
    }
    
    /// <summary>
    /// Checks input parameters to determine whether
    /// users the may edit
    /// </summary>
    /// <returns></returns>
    private bool UserMayEdit()
    {
        bool bCardEditor = false;
    
        try
        {
            if (application.AppConfiguration["FullControl"].ToUpper() == "TRUE")
            {
                bCardEditor = true;
            }
        }
        catch (KeyNotFoundException)
        {
            MessageBox.Show("Please configure the component's security settings to enable the Active tab.", "PMDG Cards", MessageBoxButton.OK);
        }
    
        return bCardEditor;
    }
    

    The Dictionary in the SilverLight UserControl exists in the App.xaml.cs as seen here

    public partial class App : Application
    {
        public static string UserID = string.Empty;
    
        public IDictionary<string, string> AppConfiguration;
        public App()
        {
            this.Startup += this.Application_Startup;
            this.Exit += this.Application_Exit;
            this.UnhandledException += this.Application_UnhandledException;
    
            InitializeComponent();
        }
    
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            AppConfiguration = e.InitParams;
            UserID = e.InitParams["UserId"];
            this.RootVisual = new MainPage();
        }
        //...
    }
    

    What can I say? It works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a silverlight user control which is bound to a Document object. the
I have created a user control in Silverlight which basically animates the size of
I have a Silverlight control which maintains a set of children. This set of
I have a silverlight control which has a reference to a silverlight enabled wcf
I have created a nice silverlight control doing exactly what I want it to
I have a button and image inside it in my silverlight user control. When
I have a Silverlight 4 user control that calls a WCF service residing within
I have a Silverlight user control that contains an ItemsControl that renders a StackPanel
I'm just getting started with silverlight. Basically I have a silverlight user control that
I want to be able to dynamically mirror a silverlight control. suppose i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.