Interview Questions administrator

Best SharePoint administrator Interview Questions and Answers with topic wise:


Recycle Bin | MMS | ManagedVsCrawledProperties |

Tuesday, December 18, 2012

App web Vs Host Web

The special website to which the app is deployed is called an app web. The website to which the app is installed is called the host web. Although the app web has its own isolated domain, it is in the same site collection as the host web.
SharePoint components are deployed to a special website with its own domain. This is called the app web.

SharePoint hosted vs Cloud hosted apps


Difference between SharePoint hosted apps and cloud hosted apps?
An app for SharePoint can have both SharePoint-hosted and cloud-hosted components. The app does not (actually cannot) contain custom code that executes on the SharePoint servers, administrators are assured of its safety.

Cloud hosted:  
  1. This type of hosting is used when app has at least one remote component. It may also include SharePoint hosted components. There are two types in Cloud hosted apps.
  2. The external components [also called Remote components] are persisted in databases, servers, or cloud-based services that are external to the SharePoint farm.
  3. Cloud-Hosted Apps are also referred to as server-side apps.
  4. Cloud-Hosted SharePoint 2013 Apps include components hosted outside your SharePoint farm. Such components can be hosted on IIS servers, Apache servers, or cloud services such as Windows Azure.
  5. When it is required exactly is if we require server-side components in apps. In such situations, you must write a Cloud-Hosted App. Also known as server-side apps.

Simply way to get an idea on SharePoint 2013 apps

Apps in SharePoint 2013:
An app for SharePoint is a web application that is registered with SharePoint using an app manifest and  An app manifest is an XML file that declares the basic properties of the app along with where the app will run and what to do when the app is started.

App Model: The new app model will give us the opportunity to extend our SharePoint system with custom coding. Earlier models support Sandbox solutions and in 2013 we have both Sandbox and App models. 

List item count is zero in SharePoint apps:


If you are getting the count as zero even the data exists means that you don’t have item level permissions. Please follow up the below steps to give permissions at the list item levels in apps.




Another way to add permissions:
Just right click on “Appmanifest.xml”, select “view code” and then add the below code in it.

Sunday, December 2, 2012

SPField’s to the dropdown List programmatically:


By default, we can get the number of built-in fields or internal fields if you try to retrieve the fields in a list. My below post will help to add only the custom fields to the dropdown list by avoiding all the internal, built-in and hidden fields.

using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
    SPWeb web = site.OpenWeb(SPContext.Current.Web.ID);
    web.AllowUnsafeUpdates = true;
    SPList list = web.Lists[new Guid(listId)];
    var fields = from SPField f in list.Fields
                        where !f.Hidden && f.AuthoringInfo == "" &&
                                      f.Type != SPFieldType.Attachments &&
                                      f.Type != SPFieldType.WorkflowStatus
                        orderby f.Title
                        select new { ListItem = new ListItem(f.Title, f.Id.ToString()),
                                               Readonly = f.ReadOnlyField, FieldType = f.Type };

ddlDestfield.DataSource = from g in fields where !g.Readonly &&
(g.FieldType == SPFieldType.Note || g.FieldType == SPFieldType.Text)                                                select g.ListItem;
ddlDestfield.DataBind();
ddlDestfield.Items.Insert(0, new ListItem("[Select]", "none"));
}


Note: Set f.AuthoringInfo == null [In SP2007] and Set f.AuthoringInfo == "" [In SP2010]

List of fields in a list SharePoint programmatically:



Below post will help you to get the list of columns that is displayed when you view the items in the list programtically:

var fields = from SPField f in list.Fields
                    where !f.Hidden && f.AuthoringInfo == "" &&
                                  f.Type! = SPFieldType.Attachments &&
                                  f.Title! = "SharingID" &&
                                  f.Type! = SPFieldType.WorkflowStatus
                    orderby f.Title
                    select new { ListItem = new ListItem(f.Title, f.Id.ToString()),
                                Readonly = f.ReadOnlyField, FieldType = f.Type };



 Note: we will get the null result to the “f.AuthoringInfo” in SharePoint 2007 but we can get string empty result to the “f.AuthoringInfo” in SharePoint 2010.
 So, use: f.AuthoringInfo == null [In SP2007] & f.AuthoringInfo == ""[In SP2010]

Output: We can get the list of viewable lists by default once create a sample list in SharePoint.

Thursday, November 29, 2012

SPFieldChoice to the dropdown list programatically:


  1. List Name: MyList
  2. Choice Field Name: MyChoiceField and the values are
    1. MyChoice1
    2. MyChoice2
    3.  MyChoice3
First example to set the SPChoice field default value as dropdown list default value.


          try
            {
                using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                {
                    SPWeb web = site.OpenWeb(SPContext.Current.Web.ID);
                    SPList liMyLists = web.Lists["MyList"];
                    SPFieldChoice fcTypes = (SPFieldChoice)       
                                                liMyLists.Fields["MyChoiceField"];
                    ddlChoiceField.DataSource = fcTypes.Choices;
                   //To set choice field default value as dropdown list default value.
                    ddlChoiceField.SelectedValue = fcTypes.DefaultValue; 
                    ddlChoiceField.DataBind();
            }
            catch (Exception ex)
            {
               //code
             }
OutPut:


Wednesday, November 21, 2012

SPSecurity.Runwithelevatedprivileges: Best practice


Download it:
https://sites.google.com/site/sasivalipireddy/home/RunWithElevatedPrivileages_ALL.pdf


  1. RunWithElevatedPrivileges?
  2. Why can’t we use RunWithElevatedPrivileges in event handlers?
  3. Impersonation Improvements in SharePoint 2010 Event Receivers?
  4. Best recommended practice use of it?
  5. Best recommended practice to use of it in Event Receivers?
  6. Best recommended practice to use of it in Feature Receivers?
  7. RunWithElevatedPrivileges in visual studio workflows:
  8. Is RunWithElevatedPrivileges allowed in sandbox solution?
  9. By using which credentials the RunWithElevatedPrivileges will run?
  10. Difference between SPSecurity.CodeToRunElevated and SPSecurity. RunWithElevatedPrivileges?

Enhancements in event receivers in SharePoint 2010

Before learning new enhancements in sharepoint2010, we have to know why they were enhanced. So that we can remember new features easily, below are the limitations on sharepoint2007 what I covered in my development career.
  • Cannot hook the events to a particular SharePoint lists.
  • Need to use standard pre-defined error page when canceling the events, which is not so intuitive for the end users
  • No JavaScript alert instead of redirecting to pre-defined error page
  • No events for SPWeb object.

Tuesday, November 20, 2012

SharePoint Interview Questions and Anwers: Permissions

  1. SPWeb.EnsureUser method?
  2. Difference between SPWeb.Users, SPWeb.AllUsers, SPWeb.SiteUsers?
  3. How to create custom permission levels?
  4. Difference between “Limited Access” and “Read”?
  5. Anonymous access?

SharePoint Interview Questions and Answers: SPSiteDataQuery

Download: https://sites.google.com/site/sasivalipireddy/home/SPSiteDataQuery.png 
  1. What are SPQuery and SPSiteDataQuery?
  2. SPSiteDataQuery properties?
  3. Difference between SPQuery and SPSiteDataQuery?
  4. What are the limitations of both?
  5. How the SPQuery and SPSiteDataQuery return?
  6. How to set the row limit to the both?
  7. Searching scope levels of SPQuery and SPSiteDataQuery?
  8. What is the max limit of querying the lists using SPSiteDataQuery?
  9. Is it possible to query the records across the site collection level using SPSiteDataQuery?
  10. What is the default row limit value for the SPQuery?

SharePoint Interview Questions and Answers: IIS, WP, AppPool


What is IIS?
IIS (Internet Information Server) is one of the most powerful web servers from Microsoft Corporation that is used to host the Asp.Net web application. IIS has its own ASP.NET process engine to handle the ASP.NET request. So, when request comes from client to server, IIS takes the request and process it and send response back to the clients.
IIS means when request comes from client to the server a lot of operation is performed before sending response to the client. This is about how IIS process the request.

Wednesday, November 7, 2012

SharePoint Interview Questions and Answers:Pages


Preparing answers to the below questions. Will update you the soon.

Difference between Application pages and site pages?
Availability of site pages and application pages and when can we use it?
Handling code techniques to the application pages and site pages?
From which class both the application pages and site pages will inherit?
How to create an application pages and site pages?
Difference between ghosting and unghosting?

Saturday, October 20, 2012

SPContentDatabaseSequence cannot upgrade an object whose build version is too old


The Issue is: Sequence cannot upgrade an object whose build version [12.0.0.6421] is too old. Upgrade requires [14.0.4762.100] or higher:

Today I tried the migration of content database from SharePoint 2007 to SharePoint 2013. So, I have taken the backup of content database from SharePoint 2007 and restored it in SharePoint 2013 server and then I tried to attach the restored content database to the SharePoint 2013 web application but I got the below exception:
Sequence cannot upgrade an object whose build version [12.0.0.6421] is too old. Upgrade requires [14.0.4762.100] or higher:

Friday, October 19, 2012

SharePoint Interview Questions And Answers: Content database


  1. What is mean by content database?
  2. What is the max recommended SharePoint content database size?
  3. Why my Content Databases are named WSS_Content_<Guid>?
  4. Difference between configuration database and content database?
  5. Can we restore the content database to the existing web application using central administration?         
  6. How to add content database to the web application?
  7. How to delete the content database from the web application?
  8. How to move Site Collections between Content Databases?
  9. How can I check my content database size?
  10. How can we attach more than one content database to a single web application?
  11. Is it possible to have multiple content databases for a single Site Collection.?
  12. How to get site collection list per content database?
  13. How to change the existing database name using central administration?
  14. How to monitor the content database size?
Here are the answers to the above questions:

Tuesday, October 16, 2012

Get current DayOfWeek in SharePoint:DatetimeControl:



We can get the current day of week easily by using “System.DateTime” control.


We cannot get the current Day of week using “DateTimeControl” directly but there is an option to get the day of week indirectly by using the “SelectedDate” property of SharePoint DateTimeControl.

Monday, October 15, 2012

SharePoint Interview Questions and Answers: MasterPage


  1. What is master page and use of it?
  2. Types of master pages in SharePoint?
  3. Is any improvements in SharePoint 2010 masterpage when compared to SharePoint 2007?
  4. Difference between asp.net master pages and SharePoint master pages?
  5. How to set our custom master page as default master page programmatically?
  6. How to configure user controls(.ascx) in master pages?
  7. How to add webparts to the master pages?
  8. Can I use .Net master pages into SharePoint directly?
  9. How to configure the images, css, style sheets in master pages?
  10. What is delegate control and use of it in SharePoint master pages?
  11. What are all types of delegate controls in master pages?
  12. What all are contentplaceholders in master pages?
  13. I have developed one custom master page and I want to set my custom master page as default master for every newly site collections, site, web etc.?
  14. Difference between SharePoint foundation master pages and SharePoint server master pages?
  15. How to set the custom master as default master to the site in both SharePoint foundation 2010 and SharePoint server2010?
  16. How to set the same masterpage to the child sites in both SharePoint foundation 2010 and SharePoint server2010?
  17. How to hide the “Home” tab(means first node on topNavBar) in master page 2010?
  18. Difference between deploying masterpage using farm solution and sandbox solution?
  19. Can we deploy published site master page into SharePoint foundation sites?
  20. Masterpage and page layouts options missing in the left navigation in SharePoint designer2010?
  21. Event receivers with custom application pages in SharePoint 2010?
  22. What’s the difference between MasterPageFile and DynamicMasterPageFile?
  23. What is the difference between deploying custom master pages either using sandbox and farm solution?   

Masterpage provides layouts for set of pages. Master Pages are a template that other pages can inherit from to keep consistent functionality. The pages that inherit from Master Pages are referred to as content pages.

Monday, September 17, 2012

BreadCrumb In SharePoint 2010


Breadcrumb in SharePoint:
I want to develop a breadcrumb that should have to show up the below structure.

                    Root Node-->Parent Node-->Current Node.

Approach 1:
I tried the use the existing SharePoint introduced breadcrumb.

Tuesday, September 4, 2012

Client side validation of ASPX server controls with Best example

This is a simple validation control at the client side using JavaScript.  Here we have to perform the server side controls validation at the client-side using JavaScript. In below “RadiobuttonList” is server control and we had to perform validation at the client-side first once button click operation performed.

Why need it /Use of it:
The button click operation will not continue/Perform if you select the  “No” option in the radiobuttonlist. For this reason, we have to perform client-side validations using JavaScript for Asp.net server controls.

<td>
 <div>
  <asp:RadioButtonList ID="radiobuttonList1"  
    CssClass=" radiobuttonList1class" RepeatDirection="Horizontal"
    RepeatColumns="2" runat="Server">
    <asp:ListItem Text="Yes" Value="1"  Selected="True" />
    <asp:ListItem Text="No" Value="0" />
   </asp:RadioButtonList>
 </div>
</td>
<td>                             
 <asp:Button ID="btnSubmit" Text="Submit" OnClientClick="return
  btnsubmit_OnClientClick();" OnClick="btnSubmit_OnClick" runat="server"/>
</td>

var flag = true;
    function btnsubmit_OnClientClick()  {
         if (Page_IsValid) //server-side validation
         {
            var IsRequest = false;
            var radioObj = document.getElementById("<%=rbNeedBBAccount.ClientID %>");
            var radioList = radioObj.getElementsByTagName('input');
            for (var i = 0; i < radioList.length; i++) {
                if (radioList[i].checked) {

                    if (radioList[i].value == 1) {
                        flag = true;
                    }
                    else {
                     alert("Ur Request for xx  can’t be processed, as Need for xx  account field is set to NO.");
                        flag = false;
                    }
                }
            }
        }
        return flag;
    }

Note:
  1. If you are using more than one Validation Groups in page, so you need to explicitly specify the group.
  2. Best reference URL for Asp.Net Validation using JavaScript:
    1. http://praveenbattula.blogspot.in/2009/10/client-side-validation-of-aspx.html

Wednesday, August 29, 2012

Adding/Removing users to/from the group:

Note: We have to check before adding/removing users to/from the group and also check the users already exists or not in group. 
 
public void AddDeleteUsersInGroup(User user)
        {
            string GroupName = string.Empty;
            if (user.IsAdmin.HasValue && user.IsAdmin.Value)
                GroupName = "Group Owners";
            else if (user.IsApprover.HasValue && user.IsApprover.Value)
                GroupName = " Group Members";
            else
                GroupName = " Group Visitors";

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(SPContext.Current.Web.Url))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        try
                        {
                            web.AllowUnsafeUpdates = true;
                            SPUser spUser = web.EnsureUser(user.UserName);
                            if (spUser != null)
                            {
                                SPGroup spGroup = spGatingGroup(web, GroupName);
                                if (spGroup != null && (IsUserInSPGroup(spUser, GroupName.Trim())))
                                {
                                   //For adding user to the group
                                      spGroup.AddUser(spUser);
                                   //For removing user to the group
                                    spGroup.RemoveUser(spUser);
                                    spGroup.Update();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            web.AllowUnsafeUpdates = false;
                        }
                    }
                }
            });
        }