In this exercise we will open a default page based on the user.
Eg:: If user is a Approver we will open review.aspx
and if user is a contributor we will open contribute.aspx
server side code
·
SPWeb spWeb =
SPContext.Current.Web;
spWeb.AllowUnsafeUpdates = true;
SPFolder objFolder = spWeb.RootFolder;
objFolder.WelcomePage = "pages/myideas.aspx";
spWeb.AllowUnsafeUpdates = true;
SPFolder objFolder = spWeb.RootFolder;
objFolder.WelcomePage = "pages/myideas.aspx";
foreach(SPGroup group in spWeb.CurrentUser.Groups)
{
if(group.Name == "IGApprovers")
{
objFolder.WelcomePage = "pages/Review.aspx";
}
else if(group.Name == "IGContributor")
{
objFolder.WelcomePage = "pages/contribute.aspx";
}
}
objFolder.Update();
spWeb.AllowUnsafeUpdates = false;
{
if(group.Name == "IGApprovers")
{
objFolder.WelcomePage = "pages/Review.aspx";
}
else if(group.Name == "IGContributor")
{
objFolder.WelcomePage = "pages/contribute.aspx";
}
}
objFolder.Update();
spWeb.AllowUnsafeUpdates = false;
Client side code:
use the
spsecuritytrimmed control This basically conditionally formats controls on the page dependent on their permission.
You need to copy the redirect page layout and then using Designer edit the copy .
You then need to wrap the each redirector control in spsecuritytrimmed control. I've never seen this done using a group though(also think about setting the page mode so this only works when in display not in edit)
<SharePoint:SPSecurityTrimmedControl ID="SecurityControl" PermissionContext="CurrentSite" Permissions="ManagePermissions" runat="server" >
<PublishingWebControls:RedirectControl SecondsBeforeRedirect="5" runat="server"/>
<SharePointWebControls:FormField id="RedirectUrlField" FieldName="RedirectURL" runat="server"/>
</SharePoint:SPSecurityTrimmedControl>
No comments:
Post a Comment