sharepoint-2007 interview questions
Top sharepoint-2007 frequently asked interview questions
I have a strong gut feeling that using SharePoint RunWithElevatedPrivileges
should be avoided like the plague, but need to convince some others as to exactly why. Here's what I have.
- Spawns a new thread with elevated privileges
- Blocks other operations until the passed delegate returns
- Security problems (runs with a high level of privileges, perhaps by an end user)
- Others?
Source: (StackOverflow)
For our publishing sites we use the SPContext.Current.FormContext.FormMode
enum to work out if the current page is in edit mode. I've seen that this does not work for a team site I'm currently working on. The FormMode is always set to 'Invalid'.
However, when I click edit page on a sample page, the page does switch to edit mode so there must be some other way of knowing that a page is in edit mode. So how can I tell if I'm in edit mode for a page living in a team site?
Cheers.
Jas.
Source: (StackOverflow)
I've seen three types of group properties for an SPWeb
object - Groups
, SiteGroups
, AssociatedGroups
.
I understand that SiteGroups
will fetch all the groups in the current site collection. But what is the difference between Groups
and AssociatedGroups
. MSDN definition says that Groups
will get all the 'cross-site'(!) groups for that web site. AssociatedGroups
are fairly easily to understand just from the very name.
So what does Groups
return? Can somebody explain me with an example?
Source: (StackOverflow)
Is it possible to rename a list in Sharepoint 2007 using the web interface? I would like navigation url to change as well.
I have tried change the name using the settings option on the list. This will change the title but not the navigation url.
Source: (StackOverflow)
I am developing a WebPart (it will be used in a SharePoint environment, although it does not use the Object Model) that I want to expose AJAX functionality in. Because of the nature of the environment, Adding the Script Manager directly to the page is not an option, and so must be added programmatically. I have attempted to add the ScriptManager control to the page in my webpart code.
protected override void CreateChildControls()
{
if (ScriptManager.GetCurrent(Page) == null)
{
ScriptManager sMgr = new ScriptManager();
// Ensure the ScriptManager is the first control.
Page.Form.Controls.AddAt(0, sMgr);
}
}
However, when this code is executed, I get the following error message:
"The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases."
Is there another way to add the ScriptManager to the page from a WebPart, or am I going to have to just add the ScriptManager to each page (or master page) that will use the WebPart?
Source: (StackOverflow)
How to create a lookup field for the Choice field..For eg: In a list i have Choice field and i have to create an lookup column in other list pointing to this choice field ..When i select this list this column is not appearing in the dropdown...Please let me know if there is any Limitation for that
Source: (StackOverflow)
Sometimes we need to perform small administrative tasks in SharePoint. A simple PowerShell script is a really good tool for that. For instance, such script can enumerate event handlers of a list:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$site = new-object Microsoft.SharePoint.SPSite($args[0])
$site.RootWeb.Lists["MyList"].EventReceivers > C:\MyListHandlers.txt
It's known that objects like SPSite
and SPWeb
have to be Dispose()
-d after a call, otherwise memory leaks occur. The best would be to call
$site.RootWeb.dispose()
$site.dispose()
at the end of this script. But if this is a Powershell script which will only be run once, and we know that PowerShell cleans up after execution - is it so bad to not call dispose()?
So, my question is - is there some danger if sometimes I run scripts like this; will it affect the overall stability of SharePoint farm (or of the server on which I'm running the script)?
Source: (StackOverflow)
UPDATE An interesting time to revisit this question. Is perception still the same now that SharePoint 2010 is beginning to take hold? Certainly implementing 2010 is not without its own challenges, but is business perception one of them?
UPDATE: Our implementation is now kicking into high gear with some high profile projets going live in the coming weeks, so I am quite interested to see if the environment has changed out there.
Original Question
We have an issue within our working environment where the perception of SharePoint is either:
a) The golden bullet, the answer to all our problems.
b) An application which either does or does not solve a specific problem.
c) A frustrating tool which does not deliver their exacting requirements.
Now in my opinion SharePoint (or more specifically in our case Microsoft Office SharePoint Server 2007) is a framework on top of various lower level Microsoft technologies (IIS, ASP.Net, WSS 3.0, .Net Framework, Windows Workflow Foundation amongst others) and as such can be developed to do most anything (given time and resources).
The attitudes that have been formed in my organisation (and others I'm sure) is a combination of the Microsoft Marketing Machine and an organisaton's desire to get the 'golden bullet' in front of as many people as possible wihtout saying 'What for?' or 'Why?' or in some cases even 'How?'
Is this an attitude and perception shared by other SharePoint devs?
Source: (StackOverflow)
I try to instantiate an instance of SPSite
on the farm server in a custom process (MyApp.exe) and I give it as parameter the whole URI (http://mysite:80/). I also made sure that the account running MyApp.exe
is Site Collection Administrator
.
However, I can't make an instance of SPSite
whatever I am trying to do. It always throws a FileNotFoundException
.
Anyone got an idea?
StackTrace:
at
Microsoft.SharePoint.SPSite..ctor(SPFarm
farm, Uri requestUri, Boolean
contextSite, SPUserToken userToken)
at
Microsoft.SharePoint.SPSite..ctor(String
requestUrl) at
MyCompanyName.Service.HelperClass.GetItemStateInSharePoint(SharePointItem
item) in
C:\Workspaces\MyCompanyName\Development\Main\MyCompanyName.SharePoint\Service\HelperClass.cs:line
555
Another side note... I have a Web Application + Site collection that I can access through the browser without any problem.
Source: (StackOverflow)
My computer is in a Domain (Active Directory) and I need to get the domain name dynamically. I found the following code on the internet:
SelectQuery query = new SelectQuery("Win32_ComputerSystem");
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
{
foreach (ManagementObject mo in searcher.Get())
{
if ((bool)mo["partofdomain"])
{
this.Domain = mo["domain"].ToString();
break;
}
}
}
It works exactly as I want and returns exactly the domain name as I want (when I am logged as Administrator). If the user is not a Domain Admin, I have an Access denied
exception.
Does anybody know how to get the domain even with non-domain administrator users?
NOTE: I have found this solution on Internet System.Environment.UserDomainName;
but it only gives me a part of the domain name.
I.e. my domain is: something.domain.com
and the UserDomainName
returns only something
.
Source: (StackOverflow)
Is there a "nice" way to create a CAML query for SharePoint that does something like this?
SELECT *
FROM table
WHERE Id IN (3, 12, ...)
Or am I stuck with a nightmare of nested <Or>
nodes?
EDIT: This was my solution to generate the <Or>
nodes.
/// Simulates a SQL 'Where In' clause in CAML
/// </summary>
/// <param name="columnType">Specifies the data type for the value contained by the field.</param>
/// <returns>Nested 'Or' elements portion of CAML query</returns>
public static string CamlIn<T>(string internalFieldName, string columnType, T[] values)
{
XDocument doc = new XDocument();
XElement prev = null;
int index = 0;
while (index < values.Length)
{
XElement element =
new XElement("Or",
new XElement("Eq",
new XElement("FieldRef",
new XAttribute("Name", internalFieldName)),
new XElement("Value",
new XAttribute("Type", columnType),
values[index++].ToString())));
if (index == values.Length - 1)
{
element.AddFirst(
new XElement("Eq",
new XElement("FieldRef",
new XAttribute("Name", internalFieldName)),
new XElement("Value",
new XAttribute("Type", columnType),
values[index++].ToString())));
}
if (prev != null)
prev.AddFirst(element);
else
doc.Add(element);
prev = element;
}
return doc.ToString(SaveOptions.DisableFormatting);
}
Usage:
int[] ids = new int[] { 1, 2, 4, 5 };
string query = string.Format("<Where>{0}</Where>", CamlIn("SomeColumn", "Number", ids));
Output:
<Where>
<Or>
<Or>
<Or>
<Eq>
<FieldRef Name=\"SomeColumn\" />
<Value Type=\"Number\">5</Value>
</Eq>
<Eq>
<FieldRef Name=\"SomeColumn\" />
<Value Type=\"Number\">4</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name=\"SomeColumn\" />
<Value Type=\"Number\">2</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name=\"SomeColumn\" />
<Value Type=\"Number\">1</Value>
</Eq>
</Or>
</Where>
Also made this overload for working with Lookup Fields a bit easier
/// <summary>
/// Simulates a SQL 'Where In' clause in CAML
/// </summary>
/// <param name="lookupId">Specify whether to use the Lookup column's Id or Value.</param>
/// <returns>Nested 'Or' elements portion of CAML query</returns>
public static string CamlIn<T>(string internalFieldName, bool lookupId, T[] values)
{
XDocument doc = new XDocument();
XElement prev = null;
int index = 0;
while (index < values.Length)
{
XElement element =
new XElement("Or",
new XElement("Eq",
new XElement("FieldRef",
new XAttribute("Name", internalFieldName),
lookupId ? new XAttribute("LookupId", "TRUE") : null),
new XElement("Value",
new XAttribute("Type", "Lookup"),
values[index++].ToString())));
if (index == values.Length - 1)
{
element.AddFirst(
new XElement("Eq",
new XElement("FieldRef",
new XAttribute("Name", internalFieldName),
lookupId ? new XAttribute("LookupId", "TRUE") : null),
new XElement("Value",
new XAttribute("Type", "Lookup"),
values[index++].ToString())));
}
if (prev != null)
prev.AddFirst(element);
else
doc.Add(element);
prev = element;
}
if (values.Length == 1)
{
XElement newRoot = doc.Descendants("Eq").Single();
doc.RemoveNodes();
doc.Add(newRoot);
}
return doc.ToString(SaveOptions.DisableFormatting);
}
Source: (StackOverflow)
I am working on project where I have to access SharePoint data in C#.
I've never done this before; and have the following questions?
How would I access SharePoint data from C#? What API do I use? Are there any tutorials out there that will help me get started?
Source: (StackOverflow)
Technologies: Winforms, .NET, C#, Sharepoint Web Services
I'm currently writing a winform desktop application that is supposed to access a specific list of Sharepoint documents and custom input variables (From a Sharepoint Document Library)
http://www.infoq.com/articles/swanson-moss-web-services
This website gave me a good understanding of what web services are available, but I can't figure out from here how to access what I want.
Using the website.com/_vti_bin/Lists.asmx and website.com/_vti_bin/Dws.asmx as my web references.
com.website.Lists splist = new Project.com.website.Lists();
com.website1.Dws spData = new Project.com.website1.Dws();
splist.Credentials = new NetworkCredential("username", "password", "domain");
splist.GetList("My_list");
This was my first attempt at connecting, and it gives me a SOAPException (that's the extent of the details I can give)
Not sure if this is needed, but there are more that one sharepoint sites hosted at "website.com" (The one I'm trying to access is "website.com/sites/mysite" ) Does that change things?
I'm just trying to find out if I'm on the right track on using this service, or if I've got it all wrong
EDIT 1: leavig the original question so people understand what's going on.
@CBono: The article you linked was a great help on getting started on getting started. (I can't upvote yet :( ) I've managed to get the list, but formatting, or getting AT the data is proving difficult.
Here's what was provided:
query.InnerXml = "<Where><Gt><FieldRef Name=\"ID\" />" + "<Value Type=\"Counter\">3</Value></Gt></Where>";
viewFields.InnerXml = "<FieldRef Name=\"Title\" />";
queryOptions.InnerXml = "";
But my results looks like this:
<rs:data ItemCount="4" xmlns:rs="urn:schemas-microsoft-com:rowset">
<z:row ows_Title="" ows_Deal_x0020_ID="4055.00000000000" ows_MetaInfo="8;#Subject:SW| Deal ID:DW|4055.00000000000 vti_parserversion:SR|12.0.0.6545 _Category:SW| SVP Approved?:IW|1 vti_author:SR|DD\\admin vti_approvallevel:SR| vti_categories:VW| vti_modifiedby:SR|DD\\admin vti_assignedto:SR| Keywords:SW| vti_cachedcustomprops:VX|vti_approvallevel vti_categories Subject Deal\\ ID vti_assignedto Keywords vti_title _Author _Category Quarter-End\\ Date ContentType SVP\\ Approved? _Comments ContentTypeId:SW|0x0101004E1C496569BCDF42912D848E8085351A ContentType:SW|Document vti_cachedtitle:SR| vti_title:SR| _Author:SW| Quarter-End Date:SW|2008-10-31T00:00:00Z _Comments:SW| " ows__ModerationStatus="0" ows__Level="1" ows_Last_x0020_Modified="8;#2011-07-04 16:21:56" ows_Quarter_x002d_End_x0020_Date="2008-10-31 00:00:00" ows_ID="8" ows_owshiddenversion="3" ows_UniqueId="8;#{6594AD67-6954-4641-BDA5-8FECEDCCEAD8}" ows_FSObjType="8;#0" ows_Created_x0020_Date="8;#2011-07-04 16:20:00" ows_ProgId="8;#" ows_FileLeafRef="8;#Deal Name Q1.doc" ows_Modified="2011-07-04 16:21:55" ows_FileRef="8;#sites/site1/deals/Deal Name Q1.doc" ows_DocIcon="doc" ows_Editor="605;#Doe, John" xmlns:z="#RowsetSchema" />
<z:row ows_Title="" ows_Deal_x0020_ID="4576.00000000000" ows_MetaInfo="9;#Subject:SW| Deal ID:DW|4576.00000000000 vti_parserversion:SR|12.0.0.6545 _Category:SW| SVP Approved?:IW|1 vti_author:SR|DD\\admin vti_approvallevel:SR| vti_categories:VW| vti_modifiedby:SR|DD\\admin vti_assignedto:SR| Keywords:SW| vti_cachedcustomprops:VX|vti_approvallevel vti_categories Subject Deal\\ ID vti_assignedto Keywords vti_title _Author _Category Quarter-End\\ Date ContentType SVP\\ Approved? _Comments ContentTypeId:SW|0x0101004E1C496569BCDF42912D848E8085351A ContentType:SW|Document vti_cachedtitle:SR| vti_title:SR| _Author:SW| Quarter-End Date:SW|2011-01-31T00:00:00Z _Comments:SW| " ows__ModerationStatus="0" ows__Level="1" ows_Last_x0020_Modified="9;#2011-07-04 16:22:37" ows_Quarter_x002d_End_x0020_Date="2011-01-31 00:00:00" ows_ID="9" ows_owshiddenversion="3" ows_UniqueId="9;#{0AD9B000-3736-4B7B-9182-57C270824B8A}" ows_FSObjType="9;#0" ows_Created_x0020_Date="9;#2011-07-04 16:22:08" ows_ProgId="9;#" ows_FileLeafRef="9;#Deal Name Q4.doc" ows_Modified="2011-07-04 16:22:37" ows_FileRef="9;#sites/site1/deals/Deal Name Q4.doc" ows_DocIcon="doc" ows_Editor="605;#Doe, John" xmlns:z="#RowsetSchema" />
<z:row ows_Title="" ows_Deal_x0020_ID="80003.0000000000" ows_MetaInfo="10;#Subject:SW| Deal ID:DW|80003.0000000000 vti_parserversion:SR|12.0.0.6545 _Category:SW| SVP Approved?:IW|0 vti_author:SR|DD\\admin vti_approvallevel:SR| vti_categories:VW| vti_modifiedby:SR|DD\\admin vti_assignedto:SR| Keywords:SW| vti_cachedcustomprops:VX|vti_approvallevel vti_categories Subject Deal\\ ID vti_assignedto Keywords vti_title _Author _Category Quarter-End\\ Date ContentType SVP\\ Approved? _Comments ContentTypeId:SW|0x0101004E1C496569BCDF42912D848E8085351A ContentType:SW|Document vti_cachedtitle:SR| vti_title:SR| _Author:SW| Quarter-End Date:SW|2011-01-31T00:00:00Z _Comments:SW| " ows__ModerationStatus="0" ows__Level="1" ows_Last_x0020_Modified="10;#2011-07-04 16:23:15" ows_Quarter_x002d_End_x0020_Date="2011-01-31 00:00:00" ows_ID="10" ows_owshiddenversion="3" ows_UniqueId="10;#{07543C39-F299-4085-82CE-F059257796EA}" ows_FSObjType="10;#0" ows_Created_x0020_Date="10;#2011-07-04 16:22:56" ows_ProgId="10;#" ows_FileLeafRef="10;#Deal Name Q3.doc" ows_Modified="2011-07-04 16:23:15" ows_FileRef="10;#sites/site1/deals/Deal Name Q3.doc" ows_DocIcon="doc" ows_Editor="605;#Doe, John" xmlns:z="#RowsetSchema" />
<z:row ows_Title="" ows_Deal_x0020_ID="3319.00000000000" ows_MetaInfo="11;#Subject:SW| Deal ID:DW|3319.00000000000 vti_parserversion:SR|12.0.0.6545 _Category:SW| SVP Approved?:IW|1 vti_author:SR|DD\\admin vti_approvallevel:SR| vti_categories:VW| vti_modifiedby:SR|DD\\admin vti_assignedto:SR| Keywords:SW| vti_cachedcustomprops:VX|vti_approvallevel vti_categories Subject Deal\\ ID vti_assignedto Keywords vti_title _Author _Category Quarter-End\\ Date ContentType SVP\\ Approved? _Comments ContentTypeId:SW|0x0101004E1C496569BCDF42912D848E8085351A ContentType:SW|Document vti_cachedtitle:SR| vti_title:SR| _Author:SW| Quarter-End Date:SW|2009-10-31T00:00:00Z _Comments:SW| " ows__ModerationStatus="0" ows__Level="1" ows_Last_x0020_Modified="11;#2011-07-04 16:23:55" ows_Quarter_x002d_End_x0020_Date="2009-10-31 00:00:00" ows_ID="11" ows_owshiddenversion="3" ows_UniqueId="11;#{E51AB6A9-DDE1-4F66-8E44-EDFA3D0AFF7F}" ows_FSObjType="11;#0" ows_Created_x0020_Date="11;#2011-07-04 16:23:27" ows_ProgId="11;#" ows_FileLeafRef="11;#Deal Name Q2.doc" ows_Modified="2011-07-04 16:23:55" ows_FileRef="11;#sites/site1/deals/Deal Name Q2.doc" ows_DocIcon="doc" ows_Editor="605;#Doe, John" xmlns:z="#RowsetSchema" />
</rs:data>
and I have nooooooo idea how I'd use CAML to break that apart. (Also, I'm using Sharepoint Server 2007, not 2010
Source: (StackOverflow)
I am new to Sharepoint Server, Do we have any utility to upload files from ASP.NET application.
Could you please provide your valuable answers?
Source: (StackOverflow)
SharePoint 2007 (WSS or MOSS) logs are not easy to read even on a large screen, has anyone come across a log viewer that is able to:
- Display SharePoint logs live and historical
- Filter the events by various parameters
- Cope with SharePoint's log rotation
A subset of the above features would be acceptable, as would a range of tools either WinForms or SharePoint Features.
The list below isn't in any particular order other than the order in which they came to my attention. I have posted the log viewers that I found, if you have had any experience with the products upvote/comment in the answers below.
Found so far:
- SPLogViewer - supports loading and filtering one file, does not follow/tail log displays data in a DataGrid.
- SharePoint ULS Log Parser - one click access to log files, supports filtering by Process Name, Level, Area and Category.
- Log Viewer Feature - access from Central Administration, select individual log basic filtering on category, event and trace severity, output as HTML in Central Administration.
- WSS / MOSS Log File Reader - Access to individual log files from Central Administration, standard DataGrid filtering and sorting options.
- Stefan Gordon's ULS Viewer - Open individual log, does not follow/tail log, displays data in ListView detail. Filter by secerity, process category and free form text.
- SQL Integration Services - All reporting, sorting and filtering options provided by MSSQL (Blog Post with ETL Package Download), time consuming to setup.
- LogParser - Familiar interface to IIS Administrators, pleanty of options. Setup takes too long for small installations.
- SharePoint Log Viewer - WPF, as yet untested.
- Stonebond SharePoint Log Viewer - Looks great, as yet untested.
- ULS Deobfuscator - Another WPF reader.
Source: (StackOverflow)