This link has been bookmarked by 5 people . It was first bookmarked on 13 May 2008, by Eric Wettstein.
-
01 Mar 12
-
14 Apr 09
rnornornoExecutes the specified method with Full Control rights even if the user does not otherwise have Full Control.
-
17 Mar 09
-
29 Jan 09
-
13 May 08
-
public class Worker
{
public Worker()
{}
private SPSite site = null;
private SPWeb web = null;
private SPFolder folder = null;/// <summary>
/// This Method is called throug Delegate elevatedGetSite which is definend in cmdOpenCnn_Click
/// </summary>
private void EstablishSharepoint()
{
site = new SPSite("http://srv-moss-tp1:36000");
web = site.OpenWeb();
}
/// <summary>
/// If you click the Button to establish a connection to your SharePoint-Site,
/// you run this code with elevated Privileges.
/// </summary>
private void cmdOpenCnn_Click(object sender, EventArgs e)
{
SPSecurity.CodeToRunElevated elevatedGetSite = new SPSecurity.CodeToRunElevated(EstablishSharepoint);
SPSecurity.RunWithElevatedPrivileges(elevatedGetSite);// After code execution in EstablishSharepoint(), following code will be executed
// and fills a TreeView (tv in this example) with all First-Level-Folders and their SubfoldersTreeNode MainNode = new TreeNode("Web-Folders");
TreeNode n = null;
int index = 0;foreach (SPFolder f in web.Folders)
{
n = new TreeNode();
n.Text = f.Name;
n.Tag = f.ParentWeb.Url + "/" + f.Url;
n.ToolTipText = f.ParentWeb.Url + "/" + f.Url;
index = MainNode.Nodes.Add(n);foreach (SPFolder sf in f.SubFolders)
{
n = new TreeNode();
n.Text = sf.Name;
n.Tag = sf.ParentWeb.Url + "/" + sf.Url;
n.ToolTipText = sf.ParentWeb.Url + "/" + sf.Url;
MainNode.Nodes[index].Nodes.Add(n);
}
}
tv.Nodes.Add(MainNode);
}
-
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.