Microsoft.SharePoint.WebPartPages.WebPart is provided in MOSS 2007 to provide backwards compatability with MOSS 2003 webparts.
In MOSS 2007, it is recommended to use System.Web.UI.WebControls.WebParts.WebPart instead.
System.Web.UI.WebControls.WebParts.WebPart does not provides a feature to get or provide to to other webparts.
SharePoint 2010 Moss 2007 article all about to SharePoint coding best practice and SharePoint Services Features WebParts Timerjob central admin configuration sanboxed solution etc.
Showing posts with label Sharepoint Interview Questions. Show all posts
Showing posts with label Sharepoint Interview Questions. Show all posts
Tuesday, June 11, 2013
Client Object Model vs Server Object Model in SharePoint 2010
Client Object Model
Client object model is a new feature available in SharePoint 2010. .Client object model provides a way to do the programming for a SharePoint site using scripting language such as Java Script .
List list = context.Web.Lists.GetByTitle("Title");
Client object model is a new feature available in SharePoint 2010. .Client object model provides a way to do the programming for a SharePoint site using scripting language such as Java Script .
In Client object model an xml request will be sent and then server will return JSON which is changed to appropriate object model.
Mainly 2 assemblies to be referred while working with the Client object model.
Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll
Below is the code sample for a list object from SharePoint site using Client object model :
ClientContext context = new ClientContext("http://sp2010:2012");
context.Load(list);
context.ExecuteQuery();
So, what else a developer can do with Client object model. Client object model provide a way where you can access SharePoint data with scripting language such as Java Script.
You can write simple java script code to perform all those operation. You can use CAML query to access data from SharePoint site.
Using Client object model you can do below tasks:
Get list items, Add list items, Update list items and many more.
Client object model gives result in fast manner, but there is a limitation. The limitation is, we can not access Farm Object using Client object model.
For Client object model silverlight is also an option to program for a SharePoint site.
So if you want to access Farm object then use Server object model.
Server Object Model :
Server object model contains following classes : SPFarm, SPServer, SPSite, SPSiteCollection etc.
Below is the code Sample for Server Object Model:
This code is to get the list items from a SharePoint site:
using (SPSite oSite = new SPSite(@"http://sp2010:33051"))
{
using (SPWeb oWeb = oSite.RootWeb)
{
SPList oList = oWeb.Lists["List1"];
Console.WriteLine("Items in: " + oList);
foreach (SPListItem oItem in oList.Items)
{
string firstname = oItem["Fname"].ToString();
Console.WriteLine(firstname);
}
}
}
If you want more on Client object model or Server object model then please comment your query. Your comment will be highly appreciated.
Wednesday, October 24, 2012
Enable Anonymous Access to a SharePoint 2013 site
As is the case in previous versions, you can configure SharePoint 2013 sites to be accessed by anonymous users. In this article I will show the steps needed to configure anonymous access to an existing SharePoint 2013 site.
1. Navigate to the SharePoint 2013 Central Administration in your SharePoint 2013 environment. Under Application Management section, click the “Manage web applications” link.
2. Select one of the available web applications and press the “Authentication providers” button available in the Ribbon. A modal dialog showing the authentication providers available per zone is displayed. As you can see, in a basic scenario only the “Default” zone is listed.
4. Navigate to one of the site collections you have created under the
configured web application and go to “Configure -> Site Settings”.
Under the “Users and permissions” section, click the “People and groups”
link.
5. As you can see, SharePoint 2013’s Ribbon display is an “Anonymous
Access” button that allows you to configure how anonymous users can
access to the site.
6. Press the “Anonymous Access” button in the Ribbon so the related
configuration modal dialog is shown. In this dialog you have three
configuration options, just click the first one that provides full
anonymous access to the site. Press the “OK” button.
7. Back to the “People and Groups” page, check there is a new group called “Anonymous users” available in the list.
8. We are almost done. To finish, start a new instance of a web browser
and check that you don’t need to provide credentials information since
anonymous access is enabled on the entire site.
And that’s all about how to enable anonymous access to a SharePoint 2013
site. I recommend you check out how it works in your SharePoint 2013
CloudShare environment.
Ref : link:- https://support.cloudshare.com/entries/22231202-how-to-enable-anonymous-access-to-a-sharepoint-2013-site
Friday, July 6, 2012
SharePoint 2010 Foundation server architecture
SharePoint 2010 Foundation server architecture
Microsoft SharePoint Foundation is a free version of of sharepoint 2010 offers a highly structured server-side object model that makes it easy to access objects that represent the various aspects of a SharePoint Web site.
The following diagram shows the SharePoint 2010 Foundation server architecture in relation to the collections and objects of the Microsoft.SharePoint.Administration namespace.
![]() |
Click on image to zoom |
Here is the explation of each point of the SharePoint 2010 Foundation server architecture from top to down:-
1. SPFarm : SPFarm object is the highest object within the SharePoint 2010 Foundation object model hierarchy. it is designed to interact with the configuration data store. It contains global settings for all the servers, services, and solutions that are installed in a server farm. and the Services property gets a collection representing all the services.
Sharepoint SPFarm Example: the following example shows : services and status in sharepoint server farm
SPFarm myFarm = SPFarm.Local;
SPServiceCollection myServiceCollection = myFarm.Services;
foreach (SPService myService in myServiceCollection)
{
Label1.Text += myService.Name + " " + myService.Status + "";
}
SPServiceCollection myServiceCollection = myFarm.Services;
foreach (SPService myService in myServiceCollection)
{
Label1.Text += myService.Name + " " + myService.Status + "";
}
2. SPServer : SPServer object represents a physical server computer in the server form. The Service Instances property provides access to the set of individual service instances that run on the individual computer. Use either the Servers property of the SPFarm class, or the SPServerCollection constructor, to get the collection of servers that are used in the specified server farm.
Sharepoint SPServer Example : The following example modifies the name and role of an existing server in the server farm.
SPServerCollection servers = SPFarm.Local.Servers;
SPServer myServer = servers["myExistingServer"];
myServer.Name = "NewServerName";
myServer.Role = SPServerRole.Application;
myServer.Update();
myServer.Name = "NewServerName";
myServer.Role = SPServerRole.Application;
myServer.Update();
3. SPService : SPService object represents a logical service installed in the server farm. Derived types of the SPService class include, for example, objects for Windows services, such as the timer service, search, the database service, etc. and also objects for Web services, such as the basic content publishing Web service which supports the Web applications.
Sharepoint SPService Example : The following example iterates through the timer jobs history for each service in the farm and reruns any timer jobs that have failed in the past hour.
DateTime oneHourAgo = DateTime.UtcNow.AddHours(-1);
List<Guid> rerunJobIds = new List<Guid>();
foreach (SPService service in SPFarm.Local.Services)
{
foreach (SPJobHistory entry in service.JobHistoryEntries)
{
// stop if the entry didn't occur in the last hour
if (entry.EndTime < oneHourAgo)
break;
List<Guid> rerunJobIds = new List<Guid>();
foreach (SPService service in SPFarm.Local.Services)
{
foreach (SPJobHistory entry in service.JobHistoryEntries)
{
// stop if the entry didn't occur in the last hour
if (entry.EndTime < oneHourAgo)
break;
if (entry.Status == SPRunningJobStatus.Failed &&
!rerunJobIds.Contains(entry.JobDefinitionId))
{
SPJobDefinition job = SPFarm.Local.GetObject(
entry.JobDefinitionId) as SPJobDefinition;
if (job != null)
{
job.RunNow();
!rerunJobIds.Contains(entry.JobDefinitionId))
{
SPJobDefinition job = SPFarm.Local.GetObject(
entry.JobDefinitionId) as SPJobDefinition;
if (job != null)
{
job.RunNow();
// don't rerun the same job twice.
rerunJobIds.Add(entry.JobDefinitionId);
}
}
}
}
rerunJobIds.Add(entry.JobDefinitionId);
}
}
}
}
4. SPWebService : SPWebService represents a Web service that contains one or more Web applications. The WebApplications property gets the collection of Web applications that run the service. and the Web service allows a Web browser to access the content in SharePoint sites.
Sharepoint SPWebService Example : The following example iterates through all of the Web services in a server farm and changes the maximum site count and warning site count of all the content databases that are used for each Web application.
SPWebServiceCollection webServices = new SPWebServiceCollection(SPFarm.Local);
foreach (SPWebService webService in webServices)
{
{
foreach (SPWebApplication webApp in webService.WebApplications)
{
{
if (!webApp.IsAdministrationWebApplication)
{
SPContentDatabaseCollection contentDatabases = webApp.ContentDatabases;
{
SPContentDatabaseCollection contentDatabases = webApp.ContentDatabases;
foreach (SPContentDatabase database in contentDatabases)
{
database.WarningSiteCount = 4900;
database.MaximumSiteCount = 5000;
{
database.WarningSiteCount = 4900;
database.MaximumSiteCount = 5000;
database.Update();
}
}
}
}
}
}
}
}
5. Service Application Framework : Service Application Framework provides developers the ability to build scalable middle-tier shared services. Service Application Framework applications is also very helpful while load balancing and a common management and deployment experience in SharePoint 2010.
this can be tied to a single farm or can be shared across farms.
Sharepoint Service Application Framework Example : An example of a service built on this framework is SharePoint Server search. SharePoint Server search runs on multiple application servers in a SharePoint farm.
Thursday, July 5, 2012
Sharepoint 2010 14 hive directory structure
In Sharepoint 2010 microsoft has replaced the "12 hive" directory structure that we had in SharePoint 2007/Moss2007 with "14 Hive" directory structure in sharepoint 2010.
Some of the new folders came for 14 hive in sharepoint 2010
![]() |
Click on image to zoom |
Sharepoint 2010 14 hive path
the path of 14 hive folder is: C\Program Files\Common files\Microsoft Shared\Web Server Extensions\14
This directory is the installation directory for core SharePoint 2010 Server files, and all the major task are handled by this directory.
Here i would like to explain in detail 14 hive directory structure, none of the underlying folders really have changed but a few things have been added.
Sharepoint 2010 14 hive ADMISAPI
The path for sharepoint point 2010 14 hive ADMISAPI folder is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\14\ADMISAPI
Use of the 14 hive ADMISAPI directory : - Sharepoint 2010 14 hive ADMISAPI directory contains the soap services for Sharepoint 2010 Central Administration. If 14 hive ADMISAPI directory is altered, then the remote site creation and other methods exposed in the service will not function correctly.
Sharepoint 2010 14 hive CONFIG
The path for sharepoint point 2010 14 hive CONFIG directory is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\14\CONFIG
Use of the 14 hive CONFIG directory : - Sharepoint 2010 14 hive CONFIG directory contains files used to extend IIS Web sites with SharePoint Server. If this directory or its contents are altered, Sharepoint web application provisioning will not function correctly.
Sharepoint 2010 14 hive LOGS
The path for sharepoint point 2010 14 hive LOGS directory is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\14\LOGS -
Use of the 14 hive LOGS directory : - Sharepoint 2010 14 hive LOGS directory contains setup and run-time tracing logs.
Sharepoint 2010 14 hive newly added folder
Sharepoint 2010 14 hive Policy
Path for sharepoint point 2010 14 hive Policy directory is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\Policy -
Sharepoint 2010 14 hive UserCode
Path for sharepoint point 2010 14 hive UserCode directory is : -Program Files\Common files\Microsoft Shared\Web Server Extensions\UserCode -
Use of the 14 hive UserCode directory : - Sharepoint 2010 14 hive UserCode directory contains files used to support your sandboxed solutions.
Sharepoint 2010 14 hive WebClients
Path for sharepoint point 2010 14 hive WebClients directory is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\WebClients -
Use of the 14 hive WebClients directory : - Sharepoint 2010 14 hive WebClients directory contains files related to the new Client Object Model.
Sharepoint 2010 14 hive WebServices
Path for sharepoint point 2010 14 hive WebServices directory is : - Program Files\Common files\Microsoft Shared\Web Server Extensions\WebServices -
Use of the 14 hive WebServices directory : - Sharepoint 2010 14 hive WebServices directory contains new wcf or .svc related files.
Note : You should rewrite and recompile any code that refers to files and resources in "12" Hive structure.For example, if you have redeployed all of your files into the "14" folder and emptied your "12" folder, any references to files under the "12" folder will not work.
Sharepoint STSADM Interview Questions and Answers
What is sharepoint stsadm?
Stsadm ”stands for SharePoint Team Services Administration"
It is a Command-line tool used for administration of Office SharePoint 2007 (or MOSS 2007) servers and sites and even its not Not limited to administrative needs – can be extremely helpful to developers.
It is a Command-line tool used for administration of Office SharePoint 2007 (or MOSS 2007) servers and sites and even its not Not limited to administrative needs – can be extremely helpful to developers.
Where the sharepoint stsadm is it located?
You will normally find stsadm, under C:\Program Files\Common Files\ shared\web server extensions\12\bin.
Permissions are required to perform sharepoint stsadm operations?
To use Stsadm.exe, you must be a member of the local Administrators group for the server computer.
In addition to this you definitely need access to the required sharepoint databases so that you should not get any errors while deploying sharepoint solutions.
In addition to this you definitely need access to the required sharepoint databases so that you should not get any errors while deploying sharepoint solutions.
How to cancel a stsadm deployment if it is stuck at “deploying” or “Error”
You can either try to force execute timer jobs using execadmsvcjobs command or can cancel the deployment using stsadm command
"stsadm –o cancaldeployment –id {GUID} command."
The Id here would be GUID of the timer or deployment job. You can get the Id from stsadm enumdeployment command. This will display all the deployments which are inprocess or are stuck with Error.
"stsadm –o cancaldeployment –id {GUID} command."
The Id here would be GUID of the timer or deployment job. You can get the Id from stsadm enumdeployment command. This will display all the deployments which are inprocess or are stuck with Error.
How to perform operations on File system or registry of the server with stsadm command ?
Sharepoint Stsadm does not allow you to access file system or registry. It is a tool to perform administrative tasks for SharePoint farms only.
Backup and Restore sites with Sharepoint stsadm?
For backup using sharepoint stsadm
stsadm -o backup -url "http://Siteurl" -filename C:\Backup\BackupSite.bak
For Restore using sharepoint stsadm
stsadm -o restore -url "http://retsoredsite" -filename C:\Backup\BackupSite.bak
Is stsadm backup or restore different from Import or export?
Sharepoint Stsadm Backup or retsore allows you to backup either a site collection or a complete web application. It can also overwrite the exiting site collection for the destination url.
Export or Import - This operation allows you to backup or restore a site, sub site or a SPWeb instance. You can move this site or sub site under any existing site in your farm, across multiple site collections.
Is stsadm working with SharePoint 2010?
it was a rumors that new Power Shell 2.0 will replace the stsadm tool. but sharepoint 2010 fully supports the stsadm. but for the best practice always use powershell if you are using sharepoint 2010.
Related Article : Sharepoint Stsadm Commands List
Related Article : Sharepoint Stsadm Commands List
Tuesday, January 17, 2012
Capabilities and elements are available in sharepoint sandboxed solutions
The
following capabilities and elements are available in sandboxed solutions:
- · List definitions
- · List instances
- · Onet.xml
- · WebTemplate Feature element instead of Webtemp.xml
- · Content Types/Fields
- · Navigation
- · Module/files
- · Feature callouts
- · Web Parts derived from WebPart
- · Event receivers
o SPItemEventReceiver
o SPListEventReceiver
o SPWebEventReceiver
- · Custom Actions
- · Workflows
The following capabilities and elements are
not available in sandboxed solutions:
- · Custom Action groups
- · HideCustomAction element
- · Content Type Binding
- · Web Application-scoped Features
- · Farm-scoped Features
- · Custom property Toolpart class
- · Programmatic workflow
- · Event receivers
o SPLimitedWebPartManager
- · Timer jobs
- · Visual WebParts
- · Sharepoint mapped folders(e.g. “_layouts” and “images”)
Benefits of Sharepoint sandboxed solutions
Use and
benefits of sandboxed solutions
There are two common scenarios where it is appropriate
to use sandboxed solutions:
- When an organization wants to run code for employees on a production SharePoint Server site, and that code has not been rigorously reviewed and tested.
- When a hoster wants to let the owners of hosted SharePoint Server sites upload and run custom code.
The main
benefits of using sandboxed solutions are as follows:
- Sandboxed solutions can be added to a production SharePoint Server environment without the risk of affecting processes outside the sandbox.
- Site collection administrators can deploy sandboxed solutions. This frees farm administrators from this task.
- Scalability and flexibility are increased because sandboxes run in a separate process that can be restricted by quotas, and their effect on the farm can be monitored.
- A solution does not have to be modified or recompiled if it is moved from a sandbox to running directly on the farm.
Comparison
of sandboxed and farm solutions
Aspect
|
Farm
|
Sandbox
|
Deployment process
|
Add the solution, and then
deploy it to the farm.
|
Upload the solution to a site
collection, and then activate it in the site collection.
|
Who can deploy
|
Farm administrator.
|
If the solution contains an
assembly, only a site collection administrator can deploy it. If the solution
does not contain an assembly, a user who has the Full Control permission
level at the root of the site collection can deploy it.
|
Data access
|
Unrestricted.
|
The solution can only access
content from the site collection in which it was deployed.
|
Process the solution runs in
|
Unrestricted IIS worker process
or whichever process the solution is deployed into.
|
Separate worker process that has
restricted permissions.
|
Code access security
|
The solution developer can set
the code access security policy when packaging the solution.
|
Restricted.
|
Monitoring
|
Not monitored.
|
Monitored, and limited by quotas
set by the farm administrator.
|
Load balancing
|
Varies, based on the kind of
solution.
|
Configurable separately from
non-sandboxed solutions.
|
Solution functionality
|
Unrestricted.
|
Subscribe to:
Posts (Atom)