none
Remove User from sharepoint menu target audience using C# RRS feed

  • Question

  • Hi,

    I am programmatically adding sharepoint group to sharepoint global navigation menu target audience based on some checkbox selection.

       SPNavigationNodeCollection topnav = oSPWeb.Navigation.TopNavigationBar;

                foreach (SPNavigationNode node in topnav)

                {

                   string name=node.Title;

                     string grp = node.Properties["Audience"].ToString();

                      if(dr["User Groups"]==grp.ToString())  //am checking the group name with other group name in table

                       node.Properties["Audience"] = "IMS Users" + grp ;

                 }

    Now while unchecking the checkbox i want to remove the selected user from people picker from target audience.Here the point to note is i have added the user in a sharepoint group and that group is added to target audience of sharepoint menu.BUt while unchecking i need to find the user from the group and remove the user only from the target audience alone.

    Please let me know the possible way to do?

    Saturday, February 18, 2017 8:19 AM

Answers

  • Hi Poovi,

    As the Target Audience is set to group name not user account, if you want to remove the user from Target Audience, you should also delete the user from group. Or you can create a new group without the specific user and then set the Target Audience to the new group name.

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, February 20, 2017 9:46 AM