pct403 sharepoint and wss allowing your code to work with both
Download
Skip this Video
Download Presentation
PCT403 – SharePoint and WSS: Allowing Your Code to Work with Both

Loading in 2 Seconds...

play fullscreen
1 / 13

PCT403 – SharePoint and WSS: Allowing Your Code to Work with Both - PowerPoint PPT Presentation


  • 74 Views
  • Uploaded on

PCT403 – SharePoint and WSS: Allowing Your Code to Work with Both. Eugene Rosenfeld Black Blade Associates [email protected] Overview.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' PCT403 – SharePoint and WSS: Allowing Your Code to Work with Both' - dalton-whitehead


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
overview
Overview
  • This session will focus on creating applications, web parts, and server controls that function in both a portal, WSS within portal, and WSS only environments.
  • Topics will include
    • Distinguishing between portal areas and WSS sites
    • The use of reflection to dynamically load portal-specific assemblies when present
    • Correctly handling the differing security models of the three scenarios. Application elements such as site navigation will be specifically targeted.
the similarities
The Similarities
  • Sites
  • Lists
  • Libraries
the differences
The Differences
  • Object types
    • Portal has many more object types than WSS
  • Navigation
    • Sub Areas vs. Sub Sites
      • Area hierarchy is virtualized; sites hierarchy is physical
      • Hidden Areas
      • Explicit order vs. Alphabetical order
    • Container Sites
    • Sites Directory
  • Security
    • Sites support list level security; areas do not
  • Audiences for web parts
  • Portal Listings
  • Portal Assemblies
programming frameworks
Programming Frameworks
  • SharePoint object model
  • SharePoint web services
  • Regardless of which framework we are using, we need to answer:
    • Is the code accessing a server with SPS or just WSS?
    • Is the site the code is accessing a site or an area?
sharepoint object model
SharePoint object model
  • Distinguishing between portal areas and WSS sites
    • Early binding to both WSS and SPS assemblies but detecting assembly load errors on SPS assembly
    • Early binding to both WSS but late binding to SPS assemblies
    • Using conditional compilation to create separate WSS and SPS version of the assembly
assemblies early binding
Assemblies – Early Binding
  • Conditional compilation directives
    • Pros:
      • Compile time error checking
    • Cons:
      • Two different version of each assembly
      • More complex deployment – deploy correct assembly for correct environment
      • May need to deploy different assembly if environment changes
      • More testing
      • Code must run from a server in the farm
      • Can only work against one server farm at a time
early binding code
Early Binding - Code

private void button1_Click(object sender, System.EventArgs e)

{

System.Reflection.Assembly asmWSS;

try

{

//try to load the assembly

asmWSS = System.Reflection.Assembly.Load("Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");

}

catch(Exception ex)

{

//the assembly could not load. we assume there is no WSS on this computer

asmWSS = null;

System.Diagnostics.Trace.WriteLine("Error detected: " + ex.Message + "\r\n" + ex.StackTrace, ex.GetType().Name);

}

if(asmWSS != null)

UseWSS();

}

private void UseWSS()

{

//we have a strong reference to an SPSite object

Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite("http://localhost");

MessageBox.Show(site.GetType().Name.ToString(), "SPSite object created");

}

assemblies late binding
Assemblies – Late Binding
  • Late Binding Through Reflection
    • Pros:
      • Single assembly for WSS or Portal
    • Cons:
      • Minimal compile time error checking
      • More code to manage
      • Code must run from a server in the farm
      • Can only work against one server farm at a time
late binding code
Late Binding - Code

System.Reflection.Assembly asmWSS;

try

{

//try to load the assembly

asmWSS = System.Reflection.Assembly.Load("Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");

}

catch(Exception ex)

{

//the assembly could not load. we assume there is no WSS on this computer

asmWSS = null;

System.Diagnostics.Trace.WriteLine("Error detected: " + ex.Message + "\r\n" + ex.StackTrace, ex.GetType().Name);

}

if(asmWSS != null)

{

//the assembly has loaded

//get a late bound reference to the SPSite type

Type typSPSite = asmWSS.GetType("Microsoft.SharePoint.SPSite");

//get a reference to the constructor for SPSite that has this signature:

// new Microsoft.SharePoint.SPSite("http://localhost")

// and invoke the constructor

object objSPSite = typSPSite.GetConstructor(new Type[]{ typeof(string) }).Invoke(new object[]{ "http://localhost" });

//we now have a late bound object reference to a SPSite object

MessageBox.Show(objSPSite.GetType().Name.ToString(), "SPSite object created");

}

unified web services
Unified Web Services
  • Pros:
    • Easily decide if connecting to Portal or WSS
    • Connect to remote server farms from any client
  • Cons:
    • May not work properly when using client PKI certificates for authentication
unified web services code
Unified Web Services – Code

// set up the web service calls

SiteDataWS.SiteData siteDataWS = new WindowsApplication1.SiteDataWS.SiteData();

siteDataWS.Url = this.txtURL.Text + (this.txtURL.Text.EndsWith("/") ? "" : "/") + "_vti_bin/sitedata.asmx";

siteDataWS.Credentials = System.Net.CredentialCache.DefaultCredentials;

siteDataWS.PreAuthenticate = true;

AreaWS.AreaService areaWS = new AreaWS.AreaService();

areaWS.Url = this.txtURL.Text + (this.txtURL.Text.EndsWith("/") ? "" : "/") + "_vti_bin/areaservice.asmx";

areaWS.Credentials = System.Net.CredentialCache.DefaultCredentials;

areaWS.PreAuthenticate = true;

// set up the returns for the web methods

SiteDataWS._sWebMetadata sWebMetadata;

SiteDataWS._sWebWithTime[] sWebWithTime;

SiteDataWS._sListWithTime[] sListWithTime;

SiteDataWS._sFPUrl[] sFPUrl;

string strRoles;

string[] strvRoleUsers;

string[] strvRoleGroups;

// get the web meta data information for the site

uint intRet = siteDataWS.GetWeb(out sWebMetadata, out sWebWithTime, out sListWithTime, out sFPUrl, out strRoles, out strvRoleUsers, out strvRoleGroups);

AreaWS.AreaData adArea;

try

{

// get the area information for the web id

adArea = areaWS.GetAreaData(new Guid(sWebMetadata.WebID));

}

catch

{

// we were unable to execute the area service. assume WSS only

MessageBox.Show(this.txtURL.Text + " is a site. The server has WSS, not SPS.");

return;

}

if(adArea.WebUrl == null)

// a null web url means the web id does not correspond to an area

MessageBox.Show(this.txtURL.Text + " is a site. The server has both WSS and SPS");

else

// a valid web url means the web id does correspond to an area

MessageBox.Show(this.txtURL.Text + " is an area.");

questions
Questions

Eugene Rosenfeld

Black Blade Associates

[email protected]

http://www.blackbladeinc.com

ad