Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. SharePoint API and Development in ASP.NET Creating “Hello World” application Working with.

Slides:



Advertisements
Similar presentations
Organizing List and Documents with Site Columns and Content Types Gayan Peiris Principal Consultant
Advertisements

Site Collection, Sites and Sub-sites
Developing for SharePoint with Visual Studio Jason Keicher
Programming SharePoint Object Model, Web Services, and Events Michael Morton 4/15/03.
Omicron Development 16 Union Street Medford, NJ SharePoint Object Model A Basic Overview Presented by: David Soll President and CTO Omicron Development,
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
1 of 5 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Microsoft ® Official Course Working with SharePoint Objects Microsoft SharePoint 2013 SharePoint Practice.
Managing Identity and Permissions
Becky Bertram SharePoint MVP
1 of 5 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2006 Microsoft Corporation.
Windows SharePoint Services 3.0 (WSS v3) Browser Clients MS Word Clients MS Outlook Clients Microsoft Office SharePoint Server 2007 (MOSS) Windows.
1 of 5 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Agenda Overview 2.What is SharePoint? 3.NCDOT Websites 4.Roles 5.Search 6.SharePoint Interface.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Developing Workflows with SharePoint Designer David Coe Application Development Consultant Microsoft Corporation.
INSPIRING CREATIVE AND INNOVATIVE MINDS Module 4: Adding Code to a Microsoft ASP.NET Web Form Implementing Code-Behind Pages Adding Event Procedures to.
OBJECT REFERENCE. Objective How to work with objects in SharePoint by using classes?
Welcome to the Minnesota SharePoint User Group October 8 th, 2008 SharePoint 2007 Administration Brian Caauwe Meeting # 48.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Overview Scale out architecture Servers, services, and topology in Central Administration.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Workflow Development Overview Architecture Requirements Types of workflows Stages of workflow.
Internet Technologies and Web Application Web Services With ASP.NET Tutorial: Introduction to.
Eric Maurer Copyright Keller Schroder  Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions, Version 1.1  Windows SharePoint Services.
PS SharePoSH:\> Lists & Views SharePoint + PowerShell User Group September 14, 2012.
Microsoft SharePoint Server 2010 for the Microsoft ASP.NET Developer Yaroslav Pentsarskyy
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Sites Lists Advanced Site collection administration –Moving sites –Save site as template.
HOW SHAREPOINT WORKS By Gary Newman. Root Folder Virtual Directories SP Farm DNS Iterative Forward DNS query for A host record HTTP request HTML & JS.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Definitions Collaboration – working together on team projects and sharing information,
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Customization Using SharePoint Designer 2007 Overview Editing look and feel –Master pages.
Searching Business Data with MOSS 2007 Enterprise Search Presenter: Corey Roth Enterprise Consultant Stonebridge Blog:
New & Improved Events List Relationships and Joins Large List Support Field & List Item Validation.
Session and Cookie Management in.Net Sandeep Kiran Shiva UIN:
Eric Maurer Copyright Keller Schroder 6/11/2008. Types of Customization Customize pre-installed Microsoft Web Parts i.e. Content Editor Web Part Write.
Module 6 Securing Content. Module Overview Administering SharePoint Groups Implementing SharePoint Roles and Role Assignments Securing and Auditing SharePoint.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Event Handlers Overview Classes Simple Event Handler from the SDK Deployment –Object model.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Office Server Specific Web content management –Page structure, layouts, and controls –Publishing.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Profiles and Active Directory Overview User profiles –Import from Active Directory –Creating.
Windows SharePoint Services Managing users and rights.
VITALE, CATURANO & COMPANY LTD Microsoft SharePoint Web Part Development Overview VITALE, CATURANO & COMPANY LTD SharePoint Developer Series – Web Part.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Impersonation in SharePoint Developers use impersonation when an application needs to.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Search Overview Search Features: WSS and Office Search Architecture Content Sources and.
What’s New in SharePoint 2010 SharePoint 2010 Development Primer New Developer Tools for SharePoint 2010 SharePoint 2010 Integration with PowerShell.
Michael Hofer Senior Consultant Microsoft Corporation.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Security Overview Functional security – users, groups, and permissions for sites, lists,
PS SharePoSH:\> SPSite & SPWebs SharePoint + PowerShell User Group November 21, 2012.
Microsoft SharePoint Server 2007 Technical Overview Romeo Pruno nonaka.eu.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Site Definitions and Features Overview Review of SharePoint 2003 site definitions What’s.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Course Overview Introduction Target Audiences Course Structure Virtual PC Demo.
Microsoft ® Official Course Implementing Enterprise Content Management Microsoft SharePoint 2013 SharePoint Practice.
Extending SharePoint through Web Parts and ASP.NET 최승현 대리 한국마이크로소프트.
NET Development on Microsoft SharePoint Technology Part 4: Templates, Features, and Solution Deployment Mick Badran Breeze Training Consulting Trainer.
Application Hosting and Customization Introducing Sandboxed Solutions Executing Code in the Sandbox Sandbox Resource Monitoring.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Web Parts Overview Web parts in SharePoint 2007 “Hello World” web part Typical deployment.
Windows SharePoint Services Development Part 1: Paul Appleby Application Architect Microsoft Limited.
1 of 5 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Programming the Microsoft SharePoint Products and Technologies Object Model Paul Appleby Developer & Platform Group
11 User Controls Beginning ASP.NET in C# and VB Chapter 8.
Programming the Microsoft SharePoint Products and Technologies Object Model Paul Appleby Developer & Platform Group
VITALE, CATURANO & COMPANY LTD Microsoft SharePoint Architecture & Object Model Overview VITALE, CATURANO & COMPANY LTD SharePoint Developer Series – Architecture.
Permission Management in SharePoint – Overview and best practices Toni Frankola Co-Founder & CEO, Acceleratio Ltd., Croatia.
About SharePoint Server 2007 My Sites
Building Dynamic Applications with the SharePoint Client Object Model
Programming SharePoint Object Model, Web Services, and Events
Searching Business Data with MOSS 2007 Enterprise Search
Microsoft Dynamics.
SharePoint Object Model
SharePoint Foundation 2010
A02 Creating my website NAME ______________.
Presentation transcript:

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. SharePoint API and Development in ASP.NET Creating “Hello World” application Working with WSS object model Site collection organization List manipulation Security Administration Working with Office object model User profiles Code performance and security Object model overview

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. ASP.Net Website with SharePoint Object Model Create ASP.NET website in the following url: /_layouts/

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. References to SharePoint DLLs Add a reference to Microsoft.SharePoint.dll and Microsoft.Office.Server.dll in Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Demo: “Hello World” ASP.NET Application public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { // Put user code to initialize the page here Response.Write("Hello there!"); } Visual Studio short cuts: F7 - Switch between Code (Default.aspx.cs) and Designer (Default.aspx in Design view) Ctrl+ PgDw - View HTML Source (Default.aspx in HTML view) Visual Studio short cuts: F7 - Switch between Code (Default.aspx.cs) and Designer (Default.aspx in Design view) Ctrl+ PgDw - View HTML Source (Default.aspx in HTML view)

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Site Collection Organization In this section we will cover the basics of working with site collections: Getting current website Getting lists for the website Getting all websites in a site collection

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Getting the Current Website using Microsoft.SharePoint; SPWeb web = SPContext.Current.Web; labelMessage.Text = web.Title;

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Lists and List Items for the Current Website TreeNode webNode = new TreeNode(web.Title); treeWeb.Nodes.Add(webNode); SPListCollection lists = web.Lists; foreach (SPList list in lists) { if (list.Fields.ContainsField(“Title")) { TreeNode listNode = new TreeNode(list.Title); webNode.ChildNodes.Add(listNode); SPListItemCollection items = list.Items; foreach (SPListItem item in items) { TreeNode itemNode = new TreeNode(item.Title); listNode.ChildNodes.Add(itemNode); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Site Collection Navigation SPSite siteCollection = SPContext.Current.Site; SPWeb rootWeb = siteCollection.RootWeb; TreeNode rootNode = new TreeNode(rootWeb.Title); treeSiteCollection.Nodes.Add(rootNode); addSubWebsToTree(rootWeb, rootNode);

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Site Collection Navigation Recursion private void addSubWebsToTree(SPWeb currentWeb, TreeNode currentNode) { foreach (SPWeb subWeb in currentWeb.Webs) { TreeNode subWebNode = new TreeNode(subWeb.Title); currentNode.ChildNodes.Add(subWebNode); addSubWebsToTree(subWeb, subWebNode); subWeb.Dispose(); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Demo: Site Organization Classes 1.Use SPContext, SPSite, SPWeb, SPWebCollection, SPListCollection, and SPList classes

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Lab: Exercises 1-2 Perform exercises from Basic SharePoint API Development Lab

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. List Manipulation In this section we cover how to create new data Create a list Create columns in the list Modify a view for the list Add new list item for the list

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Creating a list SPWeb web = SPContext.Current.Web; web.AllowUnsafeUpdates = true; SPList list; try { list = web.Lists["Student Assignments"]; } catch(Exception ex) { System.Guid listID = web.Lists.Add("Student Assignments", "", SPListTemplateType.Tasks); list = web.Lists[listID]; }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Creating a column in a list SPFieldCollection fields = list.Fields; SPField gradeField; if (fields.ContainsField("Grade")) { gradeField = fields["Grade"]; } else { fields.Add("Grade", SPFieldType.Number, false); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Adding Grade field to default view of the list SPView defaultView = list.DefaultView; if (!defaultView.ViewFields.Exists("Grade")) { defaultView.ViewFields.Add("Grade"); defaultView.Update(); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Creating a new list item SPListItemCollection items = list.Items; SPListItem newItem = items.Add(); newItem["Title"] = "Homework 1"; newItem["DueDate"] = System.DateTime.Now; newItem["Grade"] = 5; newItem.Update();

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Demo: List Classes 1.Use SPList, SPField, SPView, and SPListItem classes

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Lab: Exercises Perform exercises from Basic SharePoint API Development Lab

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Free Style Exercise: List Manipulation Free Style Exercise 1.Go through all sub sites below the current one 2.Create a list called “Inventory” with “generic list” template (if the list does not exist) 3.Add a column “Quantity” to the list (if the column does not exist) 4.Add “Quantity” column to the default view( if the column is already not included in view)

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Security In this section we cover how to work with security features: Checking if the website has unique permissions Listing all domain users and groups Listing all SharePoint groups Listing all Permissions levels Adding user to a SharePoint group Setting unique permissions for a folder

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Security Permission Inheritance SPSite site = SPContext.Current.Site; SPWeb web = SPContext.Current.Web; // Test to see if the site has unique permissions if (web.HasUniqueRoleAssignments) { Response.Write(web.Title + " does not inherit permissions "); } else { Response.Write(web.Title + " inherits permissions "); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Domain User and Group Security Principals // All domain users and groups // that are Security Principals for the website // This is the list you see in /_layouts/user.aspx SPUserCollection users = web.Users; Response.Write(" All domain user principals in this site: " + " "); foreach (SPUser user in users) { Response.Write(user.Name + " "); } // All domain users and groups within the site collection users = web.SiteUsers; Response.Write(" All users in this site collection: " + " "); foreach (SPUser user in users) { Response.Write(user.Name + " "); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. SharePoint Group Security Principals // SharePoint Groups that are Security Principals on this website SPGroupCollection groups = web.Groups; Response.Write(" All SharePoint groups in this site: " + " "); foreach (SPGroup group in groups) { Response.Write(group.Name + " "); } // All SharePoint Groups in this site collection groups = web.SiteGroups; Response.Write(" All SharePoint groups in this site collection: " + " "); foreach (SPGroup group in groups) { Response.Write(group.Name + " "); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. SharePoint Group Users // All users in "Students" SharePoint group users = web.Groups["Students"].Users; Response.Write(" All users in \"Students\" SharePoint group: " + " "); foreach (SPUser user in users) { Response.Write(user.Name + " "); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Role Definitions // Role definitions are represented as "Permissions Levels" // in user interface SPRoleDefinitionCollection roleDefinitions = web.RoleDefinitions; Response.Write(" All role definitions in this site: " + " "); foreach (SPRoleDefinition roleDefinition in roleDefinitions) { Response.Write(roleDefinition.Name + " "); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Role Assignments For the Site SPRoleAssignmentCollection webRoleAssignments = web.RoleAssignments; Response.Write(" All role assignments in this site: " + " "); foreach (SPRoleAssignment webRoleAssignment in webRoleAssignments) { Response.Write(webRoleAssignment.Member.Name + " " + webRoleAssignment.RoleDefinitionBindings[0].Name + " " + webRoleAssignment.Parent.ToString() + " "); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Adding User to a SharePoint Group web.AllowUnsafeUpdates = true; SPGroup studentsGroup = web.Groups["Students"]; SPUser userToAdd = web.SiteUsers["pilothouse\\testgroup"]; studentsGroup.AddUser(userToAdd); Response.Write("Added user successfully");

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Setting Unique Folder Permissions SPPrincipal principal = userToAdd; SPFolderCollection submissions = web.GetFolder(“Submissions").SubFolders; SPFolder newFolder = submissions.Add("testfolder"); SPListItem folderItem = newFolder.Item; folderItem.BreakRoleInheritance(true); folderItem.Update(); SPRoleAssignment folderRoleAssignment = new SPRoleAssignment(principal); SPRoleAssignmentCollection folderRoleAssignments = folderItem.RoleAssignments; SPRoleDefinitionBindingCollection folderRoleDefBindings = folderRoleAssignment.RoleDefinitionBindings; folderRoleDefBindings.Add(roleDefinitions["Contribute"]); folderRoleAssignments.Add(folderRoleAssignment);

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Demo: Security Classes 1.Use SPGroup, SPUser, SPRoleAssignment, and SPRoleDefinition classes

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Free Style Exercise: Security Free Style Exercise 1.Create a new list and give "Students" SharePoint group "Contributor" permissions in that list 2.Remove all other role assignments from that list

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Administration In this section we cover how to work with Administration objects: Listing all SharePoint web applications Listing all content databases for a web application Listing all site collections for a content database

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Iterating Through Web Applications SPWebApplicationCollection webApplications = SPWebService.ContentService.WebApplications; foreach (SPWebApplication webApplication in webApplications) { TreeNode webAppNode = new TreeNode(webApplication.Name); treeGlobal.Nodes.Add(webAppNode); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Iterating Through Content Databases and Sites SPContentDatabaseCollection contentDatabases = webApplication.Content Databases; foreach (SPContentDatabase contentDatabase in contentDatabases) { TreeNode contentDBNode = new TreeNode(contentDatabase.Name); webApplNode.ChildNodes.Add(contentDBNode); SPSiteCollection sites = contentDatabase.Sites; foreach (SPSite site in sites) { TreeNode siteNode = new TreeNode(site.Url); contentDBNode.ChildNodes.Add(siteNode); site.Dispose(); }

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Demo: Administration Classes 1.Use SPWebService, SPFarm, SPWebApplication, and SPContentDatabase classes

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Microsoft.Office.Server.UserProfiles Example using Microsoft.Office.Server.UserProfiles; UserProfileManager upm = new UserProfileManager(ServerContext.Current); UserProfile up = upm.GetUserProfile("spstraining\\administrator"); Response.Write("work is " + up[PropertyConstants.Work ].Value + " "); Response.Write("state is " + up["State"].Value);

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Demo: User Profile Classes 1.Use UserProfileManager and UserProfile classes from Microsoft.Office.Server.UserProfiles namespaces

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Code Performance Use SPWeb web = SPContext.Current.Web; SPList list = web.Lists["Tasks"]; list.Title=“deployment"; list.Description=“documenting our deployment"; list.Update(); Instead of: SPWeb web = SPContext.Current.Web; web.Lists[“Tasks"].Title = “deployment task"; web.Lists["Tasks"].Description = “Documenting our deployment"; web.Lists["Tasks"].Update(); Because it minimizes the number of trips to the database.

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Use Dispose To Free Up Memory Use foreach(SPSite site in sites) { //code site.Dispose(); } Or for(i = 0; i < sites.Count; i ++) { using(SPSite site = sites[i]) { //code } In order to avoid retaining the objects in memory.

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Code Security Use HtmlEncode method in Microsoft.SharePoint.Utilities.SPEncode to prevent execution of malicious script For example when someone enters the following title for the list “ alert(); ” Response.Write(list.Title) would cause a message box to pop up.

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Application infrastructure Web.config for storing properties Localizations using.NET standards Windows installer or xcopy deployment

Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Demo: Examining Object Model Using the SDK 1.WSS object model reference 2.Office object model reference