Friday, March 19, 2010

C# Programmatically Set audiance permissions for Sharpoint Quick launch bar

To add the links in the left navigation first we need to get all links in the quick launch bar using SPNavigationCollection class

SPWeb web = SPContext.Current.Web;
SPNavigationCollection coll = web.Navigation.QuickLaunch;

/* With SPNavigationNode class we are adding our custom links(Node) in the quick launch bar */

SPNavigationNode node = new SPNavigation(linkTitle,url,true);
/*Add the node as root in the quick launch bar*/
web.AllowUnSafeUpdates = true;
coll.AddAsFirst(node);
/*Give permissions to the link*/
node.Properties.Add("Audiance",";;;;","groupName or UserName");
node.Update();

/* Creating sub links under main links in quick launch bar */
SPNavigation subnode = new SPNavigation(linkSubTitle, subUrl,true);
node.Children.AddAsLast(subNode);
/* Providing permssions to sub links in quick launch */
subNode.Properties.Add("Audiance",";;;;","group or username");
subNode.Update();
web.AllowUnSafeUpdates = false;

thats all !!!!

3 comments:

Jack said...

Nice post. Thanks a lot for explaining C# programmatically set audience permissions for share point quick launch bar. I must say that you have provided an excellent detail in this post.
electronic signature software

Unknown said...

Excellent Post i waiting like this stuff thanks a lot.

I am requesting you please post like this stuff.

REGARDS,
SARAVANA.

Unknown said...

According to Stanford Medical, It's indeed the ONLY reason this country's women live 10 years longer and weigh an average of 19 kilos less than we do.

(And by the way, it has NOTHING to do with genetics or some secret diet and absolutely EVERYTHING about "HOW" they are eating.)

BTW, What I said is "HOW", and not "WHAT"...

TAP on this link to uncover if this brief test can help you decipher your real weight loss possibilities