Friday, November 11, 2011
Installing Sharepoint on windows 7
Thursday, November 10, 2011
Creating a Site Context Search Box that Uses SharePoint Portal Server Search Results
The following table lists and describes the items available for search when you use either the search capability in Microsoft SQL Server (on which Windows SharePoint Services is based) or the search capability in SharePoint Portal Server 2003.
Packaging and Deploying Web Parts for Microsoft Windows SharePoint Services
Prerequisites
- Familiarity with Microsoft Windows® SharePoint™ Services and/or Microsoft Office SharePoint Portal Server 2003
- Knowledge about how to create a Web Part
- Familiarity with the Web Part infrastructure
Creating Event Log Messages for a Document Library in Microsoft Windows SharePoint Services
| Event | Description |
|---|---|
| Cancel Check Out | Changes made to a checked out document are undone. |
| Check In | A document is checked in to the document library. |
| Check Out | A document is checked out from the document library. |
| Copy | A document in the document library is copied. |
| Delete | A document is deleted from the document library. |
| Insert | A new document is saved to the document library. |
| Move or Rename | A document is moved or renamed. |
| Update | An existing document or the value of a custom column in the library is edited. |
ASP.NET and SharePoint Security Policies
- Full
- High
- Medium
- Low
- Minimal
Additionally, Windows SharePoint Services defines two trust levels of its own:
- WSS_Minimal
- WSS_Medium
local_drive:\Program Files\Common Files\Microsoft Shared\web server extensions\60\config
By default, when you extend a virtual server with Windows SharePoint Services, Windows SharePoint Services sets the trust level to WSS_Minimal. This helps provide a secure trust level in which assemblies operate with the smallest set of permissions required for code to execute.
The following table outlines the specific permissions granted with the custom security policy files included with Windows SharePoint Services.
| Permission | WSS_Medium trust level | WSS_Minimal trust level |
|---|---|---|
| AspNetHostingPermission | Medium | Minimal |
| Environment | Read: TEMP, TMP, OS, USERNAME, COMPUTERNAME | |
| FileIO | Read, Write, Append, PathDiscovery:Application Directory | |
| IsolatedStorage | AssemblyIsolationByUser, Unrestricted UserQuota | |
| Reflection | ||
| Registry | ||
| Security | Execution, Assertion, ControlPrincipal, ControlThread, RemotingConfiguration | Execution |
| Socket | ||
| WebPermission | Connect to origin host (if configured) | |
| DNS | Unrestricted | |
| Printing | Default printing | |
| OleDBPermission | ||
| SqlClientPermission | AllowBlankPassword=false | |
| EventLog | ||
| Message Queue | ||
| Service Controller | ||
| Performance Counters | ||
| Directory Service | ||
| SharePointPermission | ObjectModel = true | |
| WebPartPermission | Connections = true | Connections = true |
Note By default, Windows SharePoint Services does not grant access to the Microsoft SharePoint object model. To grant access, you must raise the associated trust level by one of several methods. The next section discusses these methods.
Wednesday, October 5, 2011
Configure Item Level Permissions for Document Libraries
- Create a new Document Library (e.g. Top Secret Documents)
- Go to Document Library Settings > Permissions for this document library
- Click on Stop Inheriting Permissions command from the ribbon
- Revoke permissions for all but few important groups (e.g. Portal Owners and Portal Members).
Please note: Steps 2. – 4- are optional but workflow is going to be much simpler if there are fewer permissions to manage - Open your site in SharePoint Designer, and select Workflows option and your list from the ribbon
- Type the name for the new workflow (e.g. Customize Permissions)
- Insert a new Impersonation Step. This special step runs each activity as workflow author.
Make sure workflow author (you) has proper privileges to manage permissions for this list.
- From the list of workflow actions choose “Replace Item Permissions
- Click Replace these permissions
- In the dialog click Add
- In the Choose permission to grant dialog click Contribute, and then click Choose… button
- Add User who created current item to the Selected users list
- Click the workflow name (e.g. “Customize Permissions”) to manage workflow settings
- Make sure you have selected the correct Start options
- Publish your workflow
You can also customize this workflow and add permissions for other users as well.
Thursday, July 7, 2011
Deleting a Web Part from a page
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.WebParts;
namespace SampleCode
{
class DeleteWebPart
{
static void Main()
{
ClientContext oClientContext = new ClientContext("http://MyServer/sites/MySiteCollection");
File oFile = oClientContext.Web.GetFileByServerRelativeUrl("/sites/MySiteCollection/SitePages/Home.aspx ");
LimitedWebPartManager limitedWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared);
oClientContext.Load(limitedWebPartManager.WebParts);
oClientContext.ExecuteQuery();
if (limitedWebPartManager.WebParts.Count == 0)
{
throw new Exception("No Web Parts to delete.");
}
WebPartDefinition webPartDefinition = limitedWebPartManager.WebParts[0];
webPartDefinition.DeleteWebPart();
oClientContext.ExecuteQuery();
}
}
}
Adding a Web Part to a page
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.WebParts;
namespace SampleCode
{
class AddWebPart
{
static void Main()
{
ClientContext oClientContext = new ClientContext("http://MyServer/sites/MySiteCollection");
File oFile = oClientContext.Web.GetFileByServerRelativeUrl("Default.aspx");
LimitedWebPartManager limitedWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared);
string xmlWebPart = "" +
"
" xmlns=\"http://schemas.microsoft.com/WebPart/v2\">" +
"
"
"
"
"
"
"
"
"
"
"
"PublicKeyToken=94de0004b6e3fcc5
"
"
"
"
"
WebPartDefinition oWebPartDefinition = limitedWebPartManager.ImportWebPart(xmlWebPart);
limitedWebPartManager.AddWebPart(oWebPartDefinition.WebPart, "Left", 1);
oClientContext.ExecuteQuery();
}
}
}
Updating the title of a Web Part
using System; using Microsoft.SharePoint.Client; using Microsoft.SharePoint.Client.WebParts; namespace SampleCode { class UpdateWebPartTitle { static void Main() { ClientContext oClientContext = new ClientContext("http://MyServer/sites/MySiteCollection"); File oFile = oClientContext.Web.GetFileByServerRelativeUrl("Default.aspx"); LimitedWebPartManager limitedWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared); oClientContext.Load(limitedWebPartManager.WebParts, wps => wps.Include( wp => wp.WebPart.Title)); oClientContext.ExecuteQuery(); if (limitedWebPartManager.WebParts.Count == 0) { throw new Exception("No Web Parts on this page."); } WebPartDefinition oWebPartDefinition = limitedWebPartManager.WebParts[1]; WebPart oWebPart = oWebPartDefinition.WebPart; oWebPart.Title = "My New Web Part Title"; oWebPartDefinition.SaveWebPartChanges(); oClientContext.ExecuteQuery(); } } }
Tuesday, June 28, 2011
Fetching user names and E-mail Addresses from SPGroups
There are various groups present over a SharePoint Site. The below code can extract email addresses of all the existing users in all the groups.
Code to get the user names:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string username;
SPSite spsite = new SPSite("site url"); //Ex: http://adfsaccount:2222/
SPWeb web= spsite.RootWeb;
SPUserCollection userlist= web.AllUsers;
foreach (SPUser u in userlist)
{
username=u.Name;
}
}
}
}
Code to get the email addresses:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
SPSite spsite = new SPSite("site url"); //Ex: http://adfsaccount:2222/
SPWeb web= spsite.RootWeb;
SPUserCollection userlist= web.AllUsers;
foreach (SPUser u in userlist)
{
string email = u.Email.ToString();
}
}
}
}
Friday, June 17, 2011
Exporting a Published site / Web Part /Site Template from SharePoint 2010 Enterprise and Importing Into Standard
Normally this is because of custom or third party solutions/features, but can also be an issue with out of the box deployments moving content from an Enterprise edition to a standard edition (but not the other way around).
There is some guidance for dealing with this out there for SharePoint 2007 but not much for 2010. Having recently gone through this in a trial and error fashion, I thought that I would share what worked. Essentially, you need to remove the offending feature before you do the export, deactivating doesn’t always suffice. My case below is for a publishing site, and your mileage will vary depending on the site template that you are using. First, the offending features are uninstalled:
stsadm -o uninstallfeature -force -name WACustomReports
stsadm -o uninstallfeature -force -name BizAppsListTemplates
stsadm -o uninstallfeature -force -name IPFSSiteFeatures
stsadm -o uninstallfeature -force -name ReportListTemplate
stsadm -o uninstallfeature -force -name DataConnectionLibrary
stsadm -o uninstallfeature -force -name PremiumSite
stsadm -o uninstallfeature -force -name PremiumWeb
Then the site is exported:
stsadm –o export –url http://mysiteaddress –filename myexportfile
Once done, the export file can be imported. However, don’t forget to reinstall those features – the previous step uninstalled them from all application (read – use with caution)
stsadm -o installfeature -force -name WACustomReports
stsadm -o installfeature -force -name BizAppsListTemplates
stsadm -o installfeature -force -name IPFSSiteFeatures
stsadm -o installfeature -force -name ReportListTemplate
stsadm -o installfeature -force -name DataConnectionLibrary
stsadm -o installfeature -force -name PremiumSite
stsadm -o installfeature -force -name PremiumWeb
Your mileage may vary depending on what you have in your farm, but all you need to do is to add to the commands above with the features in question.
Web Part / Solution Deployment
follow the steps bellow.
go to START==>>All Programs==>>Microsoft SharePoint 2010 Products==>>SahrePoint 2010 management Shell.(Run it as Administrator)
to deploy particular solution run the following power shell command
Add-SPSolution "D:\WebPartZone\Eventproject_SO.wsp"
3.after deploying the solution to enable it to particular Web Application run the following command with proper web app URL.
Install-SPSolution –Identity "Eventproject_SO.wsp" –WebApplication "Url" -GACDeployment
Thursday, June 16, 2011
Add Web Part inside Master Page in Sharepoint
Programmatically retrive content database name for Sharepoint Web Application
Tuesday, June 7, 2011
Getting List of all list in a sharepoint site using client object model
Tuesday, May 17, 2011
Copy listitems from one custom list to another, then move them into subfolders.
listItem.CopyTo(destinationUrl); // Copies the item to the specified destinations
SPFile file = Web.GetFile(item.Url);
file.MoveTo("New location...with the ID_.000");
Copy file and folder recursively from local drive to SharePoint list.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;
using System.IO;
using System.Text.RegularExpressions;
namespace WindowsFormsApplication2
{
public partial class Uploder : Form
{
public Uploder()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
selectFolder.ShowDialog();
textBox1.Text = selectFolder.SelectedPath;
using (SPSite site = new SPSite(textBox2.Text))
{
using (SPWeb rootWeb = site.OpenWeb())
{
ActionDocLibRecursive(rootWeb);
}
}
}
private void ActionDocLibRecursive(SPWeb web)
{
// loop through each list in the web site
foreach (SPList list in web.Lists)
{
// check if the list is a document library
if (list.BaseType == SPBaseType.DocumentLibrary)
{
// if it is, create a document library object
SPDocumentLibrary docLib = (SPDocumentLibrary)list;
// check that the document library is not a "catalog"
// (e.g. "Master Pages & Page Layouts" .. or "Web Template Gallery")
if (docLib.IsCatalog == false)
{
LibList.Items.Add(docLib);
}
}
}
// call the recursive loop back on itself
//foreach (SPWeb subWeb in web.Webs)
//{
// // call resursive method on each sub-site of the current site
// ActionDocLibRecursive(subWeb);
//}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
button2.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
try
{
selectFolder.ShowDialog();
textBox1.Text = selectFolder.SelectedPath;
string localPath = selectFolder.SelectedPath; //Local path.
string sharePointSite = "http://blr-ws-168/"; //SharePoint site URL.
string documentLibraryName = "Documents"; // SharePoint library name.
// Make an object of your SharePoint site.
using (SPSite oSite = new SPSite(sharePointSite))
{
SPWeb oWeb = oSite.OpenWeb();
ActionDocLibRecursive(oWeb);
CreateDirectories(localPath,oWeb.Folders[documentLibraryName].SubFolders);
}
}
catch (Exception ex)
{
// MessageBox.Show("Error:" + ex.Message);
// richTextBox1.AppendText( ex.Message + "\n");
}
}
private void CreateDirectories(string path, SPFolderCollection oFolderCollection)
{
//Upload Multiple Files
foreach (FileInfo oFI in new DirectoryInfo(path).GetFiles())
{
CreateValidFileName(oFI.Name);
FileStream fileStream = File.OpenRead(oFI.FullName);
SPFile spfile = oFolderCollection.Folder.Files.Add
(oFI.Name, fileStream, true);
label4.Text = oFI.Name;
spfile.Update();
//richTextBox1.AppendText(oFI.Name + "Was Added Sucessfully\n"+ " In "+ spfile);
}
//Upload Multiple Folders
foreach (DirectoryInfo oDI in new DirectoryInfo(path).GetDirectories())
{
string sFolderName = oDI.FullName.Split('\\')[oDI.FullName.Split('\\').Length - 2];
SPFolder spNewFolder = oFolderCollection.Add(sFolderName);
spNewFolder.Update();
//Recursive call to create child folder
CreateDirectories(oDI.FullName, spNewFolder.SubFolders);
}
}
public void CreateValidFileName(string Filename)
{
string invalidChars = Regex.Escape(new string(Path.GetInvalidFileNameChars()));
string invalidReStr = string.Format(@"[{0}]+", invalidChars);
Filename = Regex.Replace(Filename, invalidReStr, "_");
}
}
}
How to programmatically download attachments from list items in Windows
Monday, May 16, 2011
Using SP.UI.ModalDialog in SharePoint 2010
- Add and Edit metadata
- Perform administrative task
- Attach documents/files
- Create a hyperlink that will be responsible for triggering your modal. Set the onclick attribute as follows:
- Implement the openDialog function in javascript.
- Create hidden fields to store the information you will need to modify the url.
- Setup the hidden fields in your Page_Load event.
- Use the hidden fields in the javascript function you wrote above.
<a href="#" onclick="javascript:openDialog(); return false;">Open Attach File</a>
<script type="text/javascript"> function openDialog() { var options = { url: http://server/_layouts/AttachFile.aspx?ListId={0F42F104-538C-4F3C-8098-0DD93C8CD779}&ItemId=246&Source=http%3A%2F%2Fdeadmines%2Fsites%2Fhorizon%2FLists%2FYear%2520End%2FMy%2520Inbox%2520%2520All%2520lists.aspx, width: 800, height: 600, title: "Attach File", }; SP.UI.ModalDialog.showModalDialog(options); } </script>
<input type="hidden" id="listId" runat="server" />
<input type="hidden" id="itemId" runat="server" />
<input type="hidden" id="sourceUrl" runat="server" />
<input type="hidden" id="webUrl" runat="server" />listId.Value = list.ID.ToString(); itemId.Value = listItem.ID.ToString(); sourceUrl.Value = list.DefaultViewUrl; webUrl.Value = web.Url;
<script type="text/javascript"> function openDialog() { var options = { url: $("#<%= webUrl.ClientID %>").val()+ "/_layouts/AttachFile.aspx?ListId=" + $("#<%= listId.ClientID %>").val() + "&ItemId=" + $("#<%= itemId.ClientID %>").val() + "&Source=" + $("#<%= sourceUrl.ClientID %>").val(), width: 800, height: 600, title: "Attach File", }; SP.UI.ModalDialog.showModalDialog(options); } </script>
varoptions = SP.UI.$create_DialogOptions();
options.url = FormPath;
options.width = FormWidth;
options.height = FormHeight;
options.allowMaximize = false;
options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
SP.UI.ModalDialog.showModalDialog(options);
}
alert(‘dialogResult’ + result + ‘\nreturnValue’+ returnValue);
{
SP.UI.Notify.addNotification(‘You chose the OK button’);
document.title = returnValue;
}
SP.UI.Notify.addNotification(‘You chose the Cancel button’);
}
Featured Posts
Kali Linux Remote Desktop: Access GNOME from Windows Using Native RDP
Kali Linux + GNOME 50 + GNOME Remote Desktop + Windows Remote Desktop (MSTSC) Getting a full GNOME desktop remotely on Kali Linux can be ...
-
public struct CoOrds { public int x, y; public CoOrds( int p1, int p2) { x = p1; y = p2; } }
-
LM Studio Overview LM Studio is a desktop application designed for developing and experimenting with large language models (LLMs)...