.Net & SharePoint '07

Technical blog for .Net and all SharePoint 2007 related Information

About the author

Me(Prince) and my wife are B.E in I.T & C.S.E respectively.  I a certified MCPD: Web from 2007 Dec. I am Intrestes in Web Application, MOSS, EPM, etc.
Now working with Deira International School, as IT Application & Help Manager. I have started my career as "Software Developer" @  REACH Sewn Technologies and Consulting Pvt. Ltd, Bangalore India from Oct 2004 to Feb 2006, then as "Web & Intranet Developer" @ Fosroc International Ltd, Dubai from April 2006 to Sep 2009.
You can catch me on mail@jpy-tech.com or mail@princepy.com. Or on 00971 - 50 - 4284530 

Google Translate

Tag cloud

Calendar

<<  May 2012  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

RecentComments

Comment RSS

Google Your Location


Infopath On My View

1.Infopath forms are wholly xml-centric ie the forms are based on xml schema.

2.Designers have a choice of designing form either from a scratch or to design a form based on preexisting schema.

3.Infopath views are based on XSL transforms.

4.Form developers can build various views of data and those views are rendered by XSLT automatically generated by Infopath.

5.All the Infopath data is saved in XML which helps infopath to coexist with other industry standard tools and processes in an XML oriented solution.

6.The power of XML tools  also enables infopath to serve as form User Interface in an environment which is not XML based.

7.An additional benefit with infopath since it has a rich client to fill the the forms,the user that has infopath installed doesn't need to be online to fill the forms.

8.Infopath has capability to capture the form locally to open it later.

9.If the form is hosted in server when user opened the form,infopath captures the form template locally so that user can continue working with the form even its original template location is no longer available.

10. Infopath has set of controls like radiobuttons,checkboxes etc.

11.In addition it provides spell checking out of the box.

12.Finally in an organisation that has public key infrastructure ,infopath provides capability to digitally sign the forms.

 

 Limitations Of Infopath 2003:

1.Users were required to have infopath installed on their desktops to fill in infopath foms.This limited usage to internet scenerios form for users outside the organisation still had to be implemented by other means.

 2.In the area in which it was best suited -internet applications-a form solution generally requires a workflow solution.

These limitations were overcomed in infopath 2007:

1.The new Microsoft Office Infopath Forms Services provides a capability to publish infopath forms to browser based forms.As a result developer can design an infopath forms,levereage the form UI capabilities inside the firewall and publish the same form in Office SharePoint Server for consumption of user outside the firewall.

2.Microsoft Office Sharepoint Server is built on Windows Sharepoint Server and provides all collaboration capabilities inherent in that platform.In addition the newest versions of Windows Sharepoint Services provide powerful new workflow capabilities  based on Windows Workflow Foundation.

 

Other Benefits:

 

1.Controls templates with which developer can create templates of controls in  frequently used layouts or combinations.

2.Integrates with Outlook for offline folder capabilities.

3.Design checker to validate the forms.

4.Multi-select listbox.

5.Ability to publish form directly to installable MSI file.

6.Data connection libraries in Microsoft office 2007 server.

7.Built-in ability to publish to PDF or Microsoft new XPS format.

8.The trust center,to manage trusted forms.

9.Additional form events.

10. Offline caching of lookup data.

11. Infopath forms hosted in the designer when working in visual studio.

 

 Infopath Client:

1.Infopath client is straight forward: it opens a wizard that allows you to select from a number of forms in a gallery of samples,from a list of recently used forms,and from an online library of forms.

2.In addition you can design and publish forms guided by wizard in the client.

Form Templates Vs Form Data:

1.Form template is seperate from form data.Form tempelate is a new format  with .xsn extension.

2.The difference is that in paper form ,you get both question and answers,but in electronic forms the form data is stored seperately from form template.This eases storage requirements but introduces a new concern thatis meaning of answer depends upon question asked.

3.While designing electronic forms,you should put as much thought in the storage and maintainence of form template as form data.

4.Infopath makes it easier by using a schema to define form  as well as automatically understanding and maintaining of form template version.

Form Maintainence:

1.Not only infopath can open form templates from network locations for which it is designed to but it can open from network shares,web servers, and sharepoint.

2.When a developer publishes form template,form template is tagged with a location in which it is published.

3.When a form template is opened,infopath caches the form template locally so that it can be opened again when computer is offline or data files referring to form template can be opened even if the template is unavailable.

4.When the form is filled out ,the form data is tagged with parent location of the form template-this enables data file to find out template file when it is opened again.

5.When the form is reopened ,it checks to see whether parent locations is available.If yes it checks the  version of current formand version of parent form.if it is diiferent infopath asks user whether it want to download newer version of form template.

6.if the parent form is not available ,it opens the form from cache.

 Tour Of The Infopath:

1.When you first open infopath you will get Getting Started Dialog  from which you can select a form or open an existing form or design a form template.

2.Ribbon icon in the toolbar indicates that the form can be digitally signed.

 

Rich Text Fields:

1.Multi-line fields can be rich text fields,which means you can apply Word-formatting to text in the field.

Repeating and Optional Sections:

1.Infopath has the capabilities of repeating and optional sections-areas of control that can be added by the user by rules depending on the data on the form or by code.

Optional section: Optional sections can be added either by the user or by the form.

                         Optional section only insert single instance of the section.

Repeating Section:

In this mutiple copies of a section of form can be inserted.It can be added either by the user or by the form.

Repeating Table:

It has additional capability of adding header and footer.Header can contain title information and footer can contain summary information.

Horizontal Repeating Table:

This table allows user to dynamically add columns to a defined table.

Master/Detail:It has the capability of managing and navigating large quantities of data.Master control is linked to child control and filters the data presented in it based on the record selected on the master 

Bulleted list,numbered list,and plain list:- These offers various ways of simply listing data bound to repeating nodes.

Multi-select List Box- This simple variation allows the user to select multiple choices from preconfigured list.

 File and Picture Controls:

Infopath 2003 Service Pack1 added some powerful file and ink controls to infopath and they remain in infopath 2007.

When used on tablet PC,Infopath will perform text recognition on handwriting inked into text boxes and other text fields.

The ink drawing enables you to draw using a tablet stylus and save the image into the form.

Infopath also allows the user  to attach image or file to a form.

Infopath provides multiple views of form.This multiple views helps designer to make it easy for user to understand and fill the form.

a.Multipurpose Forms. b.Forms with multiple pages c.Forms in which different users get different representation of data.

 Digital Signatures:

1.Digital Signatures are the way of guarenteing that the digital content has not changed since it was submitted by the user that has signed the form.

2.To obtan digital signatures user should have digital certificate.

3.Digital certificate is a small encrypted file that acts as a private key in public/private key pair.

4.It is useful in the case when the form data is be sent outside the comany or organisation.

5.For the internal use,user can create their own certificates either by using Windows Server 2003 or other package.

6.Thus infopath provides adhoc digital signatures using either the user's typed name or an image of an actual signature.

7.In addition ,section of a form can be either co-signed or counter-signed.

8.Co-signed means multiple users can sign the form.

9.Counter signed means later signatures is in effect than prior signatures.

 Form Settings

1.You can change form settings in infopath by clicking on option button in tools menu.

2.Various settings are:

                                a.General: You can change most recently used file list,print background pictures and colors,show the fillout a form dialog on startup,and enable or disable auto advance.

                                 b.System:You can change internet security settings for infopath.This leverages security dialog for intenet explorer.

                                 c.Office;You can set office as default program for opening XML files.

                                 d.Advanced:You can set autorecover options .Infopath will automatically store form data while you are filling out forms.

                                  e.Offline mode:Infopath cache the results of data connection queries so that form operates correctly when used offline. 

Infopath Designer:

Data Type:

Data Type                                           Example                               Comments                                  Allows Formatting

Text                                         Mr.Prince                             Any Text String                                  No

Whole Number                          3245                                    Any String Of Digits                          Yes

Decimal                                    34.546                                  A decimal value                                Yes

True/False                               True                                     Can be either true/false                    No

                                                                                                                or 1/0

Hyperlink                                //ftpserver/path                     Correspond to any URL

                                                                                            datatype in XML schemas                 No

Date                                        1/13/2005                            Accepts various date formats        Yes

Time                                       12:23:45 PM                          Accepts various time formats         Yes


Tags:
Categories: Infopath 2007
Posted by jincy on Tuesday, May 19, 2009 12:56 PM
Permalink | Comments (0) | Post RSSRSS comment feed

InfoPath forms in a WebPart


Posted by admin on Sunday, February 01, 2009 12:06 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Solving "The XSN can not be used on server"

Troubleshoot the problem with the following steps:

  1. Navigate to a command prompt
  2. Navigate to this folder: %programfiles%\common files\microsoft shared\web server extensions\12\bin
  3. Execute this command on each of your XSN files: stsadm.exe -o verifyformtemplate -filename <complete path to your xsn including the name.xsn>

This will give a more detailed description about the errors.

if you are not sure if the access path is filled in for the InfoPath form you have deployed – you can rename the xsn file in the features directory to a CAB file and extract manifest.xsf from this file in this file – you should see that accessPath=”"

 

thanks : dainghia


Tags:
Categories: Infopath 2007 | VS 2005
Posted by admin on Tuesday, December 16, 2008 1:39 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Display Rich Content in an Expression Box

When you bind an Expression Box to a Rich Text field you might be surprised to find that all of the formatting and rich content are gone, and that you are left with a single-line string of plain text. Getting the rich content to display requires only a small manual modification to the view .xsl file.

In this task we will create an Expression Box bound to a Rich Text field that displays with rich content. We will also look into an issue you might experience as a result of this modification and what can be done about it. Let's start by designing a new blank form.

Create a Rich Text Box and bind an Expression Box to it:

Open the Controls task pane.

  1. Insert a Rich Text Box into the view.
  2. In the Data Source task pane, right-click field1, and then choose Expression Box.
  3. Resize the Expression Box to be the same width as the Rich Text Box above it.

Try it:

  1. Preview the form.
  2. Add some rich content to the Rich Text field, and then click outside of the field to bind the content.

The rich content is not displayed in the Expression Box. This is because InfoPath does not consider the data type of the bound field when creating an Expression Box but instead always uses the xsl:value-of element in the XSL. The xsl:value-of element converts the results of its selection to a string by calling the string() function. To allow for rich content, we must change to use the xsl:copy-of element.

Modify the view .xsl file to allow the Expression Box to display rich content:

Choose Extract Form Files from the File menu.

  1. Select a location to save your extracted form files to, and then click OK.
  2. Close InfoPath to release the lock it places on your form files.
  3. Using a text editor, open your view .xsl file.
  4. Search for the text ExpressionBox to locate the span element that represents your Expression Box control.
  5. Change the following line from: <xsl:value-of select="my:field1"/> to: <xsl:copy-of select="my:field1/node()"/>
  6. Save the view .xsl file, and then close the text editor.
  7. Reopen your form template by right-clicking the manifest.xsf file and choosing Design.

Try it:

  1. Preview the form.
  2. Add some rich content to the Rich Text field, and then click outside of the field to bind the content.

Something you might have noticed was that if you hover over the contents of the Expression Box, a blue border appears around the field. This is uncharacteristic of an expression box, and usually an undesirable effect.

There is an issue in InfoPath that causes this blue border to appear when hovering over an Expression Box modified to display rich content when a Rich Text Box bound to the same field is in the same view. To prevent this blue border from appearing on hover, you must ensure that the Expression Box does not appear in the same view as a Rich Text Box. If the two controls are in separate views, this hover effect will not occur.

thanks Greg Collins


Posted by admin on Thursday, December 11, 2008 6:10 PM
Permalink | Comments (1) | Post RSSRSS comment feed

Create a Save As dialog box in InfoPath

Just pop the following code into your VSTO project for the button click event.

FileDialog oDialog = new SaveFileDialog();
oDialog.DefaultExt = "xml";
oDialog.Filter = "InfoPath Form (*.xml)*.xml";
if(oDialog.ShowDialog() == DialogResult.OK)
{
string sFilename = oDialog.FileName;
this.SaveAs(sFilename);
}


Categories: Infopath 2007 | VSTOS
Posted by admin on Thursday, December 04, 2008 10:39 AM
Permalink | Comments (3) | Post RSSRSS comment feed

MOSS: Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

ERROR : The Web Application http://XXX at could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

Solution

  • Assign the application pool of the application which shoots ups this error message, to the pplication pool of MOSS

Categories: Infopath 2007 | MOSS | WSS | VS 2005
Posted by admin on Wednesday, November 12, 2008 2:23 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Using the Contact Selector Control & Population Default User

Using the Contact Selector Control

We have seen a number of requests on how to allow a user to enter (or select) a person’s name or logon alias and then validate that user against their Active Directory without using code. This has been especially true in workflow scenarios where User A needs to enter in the name of User B – the next person in the workflow process.

The Contact Selector control is an ActiveX control but it is a special cased control, in that it can also be used in InfoPath browser forms. To use this control there are specific steps that need to be taken – let’s take a look at those now.

Step 1: Add the Contact Selector control to your Controls Task Pane

  1. From the Controls Task Pane click the Add or Remove Custom Controls link
  2. Click the Add button
  3. On the first screen of the Add Custom Control Wizard select ActiveX control and click Next
  4. From the list of controls, choose Contact Selector and click Next
  5. Select “Don’t include a .cab file” and click Next
  6. For Binding Property select Value and click Next
  7. From the Field or group type box choose Field or group (any data type) and click Finish
  8. Click Close and then click OK

Step 2: Create the data structure for the Contact Selector Control

The Contact Selector control needs to have a specific data structure to work properly – this is documented on the “Items” tab of the Properties screen for the control; however, we’ll include that information here as well.
**IMPORTANT!** Spelling and capitalization must be exactly the same, starting with the “Person” group!

  1. Add a non-Repeating Group named: gpContactSelector
  2. Add a Repeating Group named: Person
  3. Add the following 3 text fields to the Person group: DisplayName, AccountId and AccountType

Step 3: Add and bind the Contact Selector control to the View

  1. Drag the gpContactSelector Group to the View and select “Contact Selector” from the list of controls
  2. You’re almost done…! :-)

Step 4: Add a secondary data source XML file which specifies the SharePoint server

The Contact Selector control needs to know the “context” of where the user validation should occur. These steps are not necessary if you are only displaying the form in a browser from SharePoint – in this case, it uses the context of the site from where it was provisioned; however, if you are in a mixed client/browser scenario you will need to include this XML file so forms opened in the client can use this functionality.

  1. Launch Notepad
  2. Copy and paste this one-line XML:
    <Context siteUrl="http://<servername>"/>
    **NOTE: Replace <servername> with the name of your server 
  3. Save this as: Context.xml (again – naming and capitalization are important) 
  4. Add Context.xml as a “Receive” type Secondary Data Connection to your form template and make sure the option “Include the data as a resource file” is enabled

Step 5: Test!
You should now be able to Preview the form, enter a name or logon alias, click the “Check Names” button and resolve the name! Alternatively you could click the “To” button to perform a Search if you do not know the complete name of the user.
One other important point: if this control is something you will use numerous times, this process works great to create a “Contact Selector Template Part” – then you only have to complete these steps one time!

Source: blogs.msdn.com/infopath

Filling / Selecting Specified User as Default Value for Contact selector

Clicking the Check Names button calls SharePoint's "people.asmx" web service to resolve the name. So in order for us to do this automatically, we will need to add this web service as a data connection, set the appropriate queryFields and then execute the connection.

Here are the steps you will need to follow:

  • Add a web service "receive" data connection to the "people.asmx" web service to your form template.
    NOTE: Make sure you uncheck the option to automatically get the data when the form loads.
  • From the Tools menu choose Form Options -> Open and Save
    • Click the Rules button
    • Click Add Action
      • Set a field's value
      • The field is named "string" from the ResolvePrincipals queryFields
      • The value will be the "DisplayName" field from your Contact Selector data source (the default value for this will be domain\username)
    • Click Add Action
      • Set a field's value
      • The field is named "principalType" from the ResolvePrincipals queryFields
      • Copy and paste this as the value: User SecurityGroup SharePointGroup DistributionList
    • Click Add Action
      • Query using a data connection
      • Data connection: ResolvePrincipals
    • Click Add Action
      • Set a field's value
      • The field will be the DisplayName field from your Contact Selector data source
      • The value will be the DisplayName field from the "dataFields" of your ResolvePrincipals data source
    • Repeat the above action to set the following fields:
      • AccountId from Contact Selector equals AccountName from ResolvePrincipals dataFields
      • AccountType from Contact Selector equals PrincipalType from ResolvePrincipals dataFields

So now if you set the default value of the DisplayName field to domain\user, it should auto resolve when the form is opened.


Posted by admin on Tuesday, September 23, 2008 3:19 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Infopath(VSTA):Populating & Sorting Main DataSource with Datas from Secondary DataSource

Main Data Source:

where SoNFields/SoNField is populating from Secondary Data Source "AGFileEntities" which is sorted according to SortOrder

Secondary Data Source
 

 

public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
    /* ** For  Sorting purpose ** */
    if (!FormState.Contains("InSwap"))
        FormState.Add("InSwap", false);
    /* ** For  Sorting purpose ** */

        XPathNavigator root = this.MainDataSource.CreateNavigator();
        XPathNodeIterator nodes;
        XPathNavigator clone;

        XPathNavigator pListRoot = this.DataSources["AGFileEntities"].CreateNavigator();
        SortList(pListRoot, "SortOrder", "/dfs:myFields/dfs:dataFields/dfs:IPS_Auto_Generated_File_Entities");
        nodes = pListRoot.Select("/dfs:myFields/dfs:dataFields/dfs:IPS_Auto_Generated_File_Entities[@Field_Type='Preliminary SoN']", this.NamespaceManager);
        clone = root.SelectSingleNode("/my:myFields/my:preliminarySoN/my:SoNFields/my:SoNField", this.NamespaceManager).Clone();
        while (nodes.MoveNext())
        {
            clone.SelectSingleNode("my:Title", this.NamespaceManager).SetValue(nodes.Current.GetAttribute("Title", "").Trim());
            clone.SelectSingleNode("my:Description", this.NamespaceManager).SetValue(nodes.Current.GetAttribute("Description", "").Trim());
            root.SelectSingleNode("/my:myFields/my:preliminarySoN/my:SoNFields", this.NamespaceManager).AppendChild(clone);
        }
        root.SelectSingleNode("/my:myFields/my:preliminarySoN/my:SoNFields/my:SoNField", this.NamespaceManager).DeleteSelf();

    }
    else
    {

    }
}

 

 

#region Sorting
private void SortList(XPathNavigator aListRoot, string sortBy, string itemsToSort)
{
    System.Globalization.CultureInfo currentThreadCulture =
        System.Threading.Thread.CurrentThread.CurrentCulture;

    int numPeople = aListRoot.Select(itemsToSort, NamespaceManager).Count;

    /* basic bubble sort implementation */
    for (int i = 1; i < numPeople; i++)  /* xpath is 1-based */
    {
        for (int j = i + 1; j <= numPeople; j++) // keep j ahead of i; we can index [numPeople]
        {
            /* swap (i,j) if i > j */
            string iValue = GetValue(aListRoot, itemsToSort + WrapAsIndexer(i) + "/@" + sortBy);//GetValue(itemsToSort + WrapAsIndexer(i) + "/dfs:" + sortBy);
            string jValue = GetValue(aListRoot, itemsToSort + WrapAsIndexer(j) + "/@" + sortBy);//GetValue(itemsToSort + WrapAsIndexer(j) + "/dfs:" + sortBy);

            /* Do we sort by number or string? */
            /*if (SortAsNumber) */
            /*{ */
            int iNum, jNum;
            if (!Int32.TryParse(iValue, out iNum) || !Int32.TryParse(jValue, out jNum))
            {
                /* Let InfoPath take care of the invalid datatype with its own validation, we'll keep sorting the rest */
                continue;
            }

            if (iNum > jNum)
            {
                Swap(aListRoot, itemsToSort + WrapAsIndexer(i), itemsToSort + WrapAsIndexer(j));
            }
            /*}*/

            /*else // SortAsString */
            /*{ */
            /*    if (String.Compare( */
            /*       iValue, jValue, true */ /*ignoreCase*//*currentThreadCulture) > 0)  */
           /*    { */
            /*        Swap(itemsToSort + WrapAsIndexer(i), itemsToSort + WrapAsIndexer(j)); */
            /*    } */
            /*} */

        } /* end inner-for */
    } /* end outer-for */
}
private string WrapAsIndexer(int intToWrap)
{ return WrapAsIndexer(intToWrap.ToString()); }
private string WrapAsIndexer(string strToWrap)
{ return "[" + strToWrap + "]"; }
private string GetValue(XPathNavigator aListRoot, string xpath)
{ return aListRoot.SelectSingleNode(xpath, NamespaceManager).Value; }
private void SetValue(XPathNavigator aListRoot, string xpath, string value)
{ aListRoot.SelectSingleNode(xpath, NamespaceManager).SetValue(value); }
private void Swap(XPathNavigator aListRoot, string xpath1, string xpath2)
{
    InSwap = true;

    try
    {
        XPathNavigator item1 = aListRoot.SelectSingleNode(xpath1, NamespaceManager);
        XPathNavigator item2 = aListRoot.SelectSingleNode(xpath2, NamespaceManager);

        XPathNavigator item1Clone = item1.Clone();
        item1.ReplaceSelf(item2);
        item2.ReplaceSelf(item1Clone);
    }
    finally /* always undo the reentrancy block at the end */
    {
        InSwap = false;
    }
}
private bool InSwap
{
    get { return (bool)FormState["InSwap"]; }
    set { FormState["InSwap"] = value; }
}
#endregion


Categories: c# | Infopath 2007 | MOSS | VSTOS | WSS
Posted by admin on Tuesday, September 23, 2008 3:04 PM
Permalink | Comments (0) | Post RSSRSS comment feed

SharePoint Web Services [Out of the Box Services]

There are a number of web services implemented OOTB (out of the box) in SharePoint that will address most of the common and basic tasks, from administrative tasks to search and working with list data, and much more. Below is a listing of the SharePoint web services with an overview of the functionality exposed for your reference. A simple expanded list like this helps me in working with the web services giving me a quick view of the overall services and methods available.

  • CreateContentType
  • CustomizeCss
  • DeleteContentType
  • GetActivatedFeatures
  • GetAllSubWebCollection
  • GetColumns
  • GetContentType
  • GetContentTypes
  • GetCustomizedPageStatus
  • GetListTemplates
  • GetWeb
  • GetWebCollection
  • RemoveContentTypeXmlDocument
  • RevertAllFileContentStreams
  • RevertCss
  • RevertFileContentStream
  • UpdateColumns
  • UpdateContentType
  • UpdateContentTypeXmlDocument
  • WebUrlFromPageUrl
  • Service Administration
    (_vti_adm/Admin.asmx) Administrative methods for creating deleting sites and retrieving languages used in the deployment
    • CreateSite
    • DeleteSite
    • GetLanguage
    • RefreshConfigCache
    Alerts (Alerts.asmx) Methods for working with SharePoint list item alerts
    • DeleteAlerts
    • GetAlerts
    Authentication (Authentication.asmx) Client proxy that provides user authentication for sites that use forms-based authentication
    • Login (Used to authenticate)
    • Mode (Returns the authentication mode of the current site)
    Copy (Copy.asmx) Methods to copy files between or within sites
    • CopyIntoItems (Copy document as byte array to location on server)
    • CopyIntoItemsLocal (Copy document from one location on the same server to another)
    • GetItem (Creates a byte array of a document that can be passed to theCopyIntoItems method)
    Document Workspace (Dws.asmx) Methods for managing Document Workspace sites and data
    • CanCreateDwsUrl
    • CreateDws
    • CreateFolder
    • FindDwsDoc
    • GetDwsData
    • GetDwsMetaData
    • RemoveDwsUser
    • RenameDws
    • UpdateDwsData
    Forms (Forms.asmx) Methods for returning forms that are used in the user interface when working with the contents of a list
    • GetForm
    • GetFormCollection
    Imaging (Imaging.asmx) Methods to create and manager picture libraries
    • CheckSubwebAndList
    • CreateNewFolder
    • Delete
    • Download
    • Edit
    • GetItemsByIds
    • GetItemsXMLData
    • GetListItems
    • ListPictureLibrary
    • Rename
    • Upload
    List Data Retrieval (DspSts.asmx) Perform queries against sites and list in SharePoint
    • Query (Performs queries against SharePoint lists and sites)
    Lists (Lists.asmx) Methods for working with Lists and List Data
    • AddAttachment
    • AddDiscussionBoardItem
    • AddList
    • AddListFromFeature
    • ApplyContentTypeToList
    • DeleteAttachment
    • DeleteContentType
    • DeleteContentTypeXmlDocument
    • DeleteList
    • GetAttachmentCollection
    • GetList
    • GetListAndView
    • GetListCollection
    • GetListContentType
    • GetListContentTypes
    • GetListItemChanges
    • GetListItemChangesSinceToken
    • GetListItems
    • GetVersionCollection
    • UndoCheckout
    • UpdateContentType
    • UpdateContentTypesXmlDocument
    • UpdateContentTypeXmlDocument
    • UpdateList
    • UpdateListItems
    Meetings(Meetings.asmx) Create and manage Meeting Workspace Sites
    • AddMeeting
    • AddMeetingFromICal
    • CreateWorkspace
    • DeleteWorkspace
    • GetMeetingInformation
    • GetMeetingWorkspaces
    • RemoveMeeting
    • RestoreMeeting
    • SetAttendeeResponse
    • SetWorkspaceTitle
    • UpdateMeeting
    • UpdateMeetingFromICal
    People(People.asmx) Resolve and find Principals
    • ResolvePrincipals
    Permissions (Permissions.asmx) Methods for working with permissions for a site or list
    • AddPermission
    • AddPermissionCollection
    • GetPermissionCollection
    • RemovePermission
    • RemovePermissionCollection
    • UpdatePermission
    Directory Management(sharepointemailws.asmx) Methods for managing Active Directory e-mail distribution groups and their memberships
    • ChangeContactsMembershipInDistributionGroup
    • ChangeUsersmembershipInDistributionGroup
    • CreateContact
    • CreateDistributionGroup
    • DeleteContact
    • DeleteDistributionGroup
    • GetJobStatus
    • ModifyContact
    • ModifyDistributionGroup
    • RenameDistributionGroup
    Site Data (SiteData.asmx) Methods that return metadata or list data from sites or lists
    • EnumerateFolder
    • GetAttachments
    • GetChanges
    • GetContent
    • GetList
    • GetListCollection
    • GetListItems
    • GetSite
    • GetSiteAndWeb
    • GetSiteUrl
    • GetURLSegments
    • GetWeb
    Sites(Sites.asmx) Methods for returning information about the collection or site template
    • ExportWeb
    • GetSiteTemplates
    • GetUpdatedFormDigest
    • ImportWeb
    Search(spsearch.asmx) Methods for searching via search services
    • Query
    • QueryEx
    • Registration
    • Status
    Users & Groups(usergroup.asmx) Methods for working with users role definitions and groups
    • AddGroup
    • AddGroupToRole
    • AddRole
    • AddRoleDef
    • AddUserCollectionToGroup
    • AddUserCollectionToRole
    • AddUserToGroup
    • AddUserToRole
    • GetAllUserCollectionFromWeb
    • GetGroupCollection
    • GetList
    • GetListAndView
    • GetListCollection
    • GetGroupCollectionFromRole
    • GetGroupCollectionFromSite
    • GetGroupCollectionFromUser
    • GetGroupCollectionFromWeb
    • GetGroupInfo
    • GetRoleCollection
    • GetRoleCollectionFromGroup
    • GetRoleCollectionFromUser
    • GetRoleCollectionFromWeb
    • GetRoleInfo
    • GetRolesAndPermissionsForCurrentUser
    • GetRolesAndPermissionsForSite
    • GetUserCollection
    • GetUserCollectionFromGroup
    • GetUserCollectionFromRole
    • GetUserCollectionFromSite
    • GetUserCollectionFromWeb
    • GetUserInfo
    • GetUserLoginFromEmail
    • RemoveGroup
    • RemoveGroupFromRole
    • RemoveRole
    • RemoveUserCollectionFromGroup
    • RemoveUserCollectionFromRole
    • RemoveUserCollectionFromSite
    • RemoveUserFromGroup
    • RemoveUserFromRole
    • RemoveUserFromSite
    • RemoveUserFromWeb
    • UpdateGroupInfo
    • UpdateRoleDefInfo
    • UpdateRoleInfo
    • UpdateUserInfo
    Versions (Versions.asmx) Methods for working with file versions
    • DeleteAllVersions
    • DeleteVersion
    • GetVersions
    • RestoreVersion
    Views(Views.asmx) Methods for working with list views
    • AddView
    • DeleteView
    • GetViewCollection
    • GetViewHtml
    • UpdateView
    • UpdateViewHtml
    • UpdateViewHtml2
    Web Part Pages(WebPartPages.asmx) Methods for working with Web Part Pages
    • AddWebPart
    • AddWebPartToZone
    • AssociateWorkflowMarkup
    • ConvertWebPartFormat
    • DeleteWebPart
    • ExecuteProxyUpdates
    • FetchLegalWorkflowActions
    • GetAssemblyMetaData
    • GetBindingResourceData
    • GetCustomControlList
    • GetDataFromDataSourceControl
    • GetFormCapabilityFromDataSourceControl
    • GetSafeAssemblyInfo
    • GetWebPart
    • GetWebPart2
    • GetWebPartCrossPageCompatibility
    • GetWebPartPage
    • GetWebPartPageConnectionInfo
    • GetWebPartPageDocument
    • GetWebPartProperties
    • GetWebPartProperties2
    • RemoveWorkflowAssociation
    • RenderWebPartForEdit
    • SaveWebPart
    • SaveWebPart2
    • ValidateWorkflowMarkupAndCreateSupportObjects
    Webs(Webs.asmx) Methods for working with sites and subsites
    MOSS Search (Search.asmx) Methods for searching via MOSS (Microsoft Office SharePoint Server) Search services, which also includes a method to retrieve the managed search properties
    • GetSearchMetadata (Search managed properties)
    • Query
    • QueryEx
    • Registration
    • Status

    Source :geekswithblogs.net

    Posted by admin on Monday, September 22, 2008 11:46 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    SPSecurity.RunWithElevatedPrivileges with InfoPath

    If you want to use SPSecurity.RunWithElevatedPrivileges with InfoPath 2007,  you need to setup / do the following things

    1. You should develop the InfoPath in the server Itself because u need to attach reference to VSTA for
      1. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll
      2. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.Security.dll
      3. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.sharepoint.portal.dll
      4. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.Portal.SingleSignon.dll
      5. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.Portal.SingleSignon.Security.dll
    2. Give Full Control for form option of InfoPath

    The commom error if u didn't attach 1.2,1.3,1.4,1.5 is that when you test your form in InfoPath, It won't show error. But when u post/install in server and test ,It will fail by showing .....

    -----------------------------------------------------------------------------------------------------------------------

    Server Error in '/' Application.
    ---------------------------------------
    The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.Runtime.InteropServices.COMException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [COMException (0x8102006d): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.]
    Microsoft.SharePoint.Library.SPRequestInternalClass.UpdateRoleAssignment(String bstrUrl, Guid& pguidScopeId, Int32 lPrincipalID, Object& pvarArrIdRolesToAdd, Object& pvarArrIdRolesToRemove) +0
    Microsoft.SharePoint.Library.SPRequest.UpdateRoleAssignment(String bstrUrl, Guid& pguidScopeId, Int32 lPrincipalID, Object& pvarArrIdRolesToAdd, Object& pvarArrIdRolesToRemove) +119
    [SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.]
    OfficialMail.WebParts.TestWebPart.btn_Click(Object sender, EventArgs e) +94
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

    ---------------------------------------------------------------------------------------------------------------------------------------------------------

    Correct way to use "RunWithElevatedPrivileges"Eg..

    using (SPSite oSite = new SPSite(url))
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
               {
                   SPWeb myWeb = oSite.OpenWeb();
                   // Now all the object which are derived from myWeb (basically object created inside the "RunWithElevatedPrivileges",
                   // can do any sort of complex things, this part will run under system account so their wont be any problem of security issue
                   // if u want to do any sort of updation using SP**** u need to use
                  
                  
                   /****/
                   using (SPSite site = new SPSite(myWeb.Site.ID))
                   {
                       bool site_AllowUnsafeUpdates = site.AllowUnsafeUpdates;
                       site.AllowUnsafeUpdates = true;
                       // ......................................
                   }
                   /****/

               });
            }

     

    SharePoint Elevated Privilege without RunWithElevatedPrivelege by soumya dasari

    You may need to elevate privilege if the current user doesn't have permission to read that object from the SPSite. In this case, you'll need to elevate privilege just to get the user token, but we don't want to perform any operations inside RunWithElevatedPrivilege, we only want to get a token out (which is basically a simple byte array). You could also cache the system token in the application if you needed to.

    Best Practices for Elevated Privilege in SharePoint:
    Elevated Privilege can be used to bypass or work with security, and can be performed either through SPSecurity or through impersonation techniques involving the SPUserToken and the SPSite class. It's one of the most misunderstood aspects of the SharePoint API, but in general you should always prefer impersonation using the SPSite class and SPUserToken objects. Here's my list of best practices for elevated privilege code in SharePoint that will help you create more reliable applications for the enterprise.

    • Avoid using SPSecurity.RunwithElevatedPrivilege to access the SharePoint object model. Instead, use the SPUserToken to impersonate with SPSite.
    • If you do use SPSecurity.RunwithElevatedPrivilege, dispose of all objects in the delegate. Do not pass SharePoint objects out of the RunwithElevatedPrivilege method.
    • Only use SPSecurity.RunwithElevatedPrivilege to make network calls under the application pool identity. Don't use it for elevation of privilege of SharePoint objects.
    • Always use the SPSite constructor with an SPUserToken to create an elevated privilege security context in SharePoint. To impersonate the system, use the SystemAccount.UserToken property of the current SPSite context, such as:
      var site = new SPSite(SPContext.Current.Site.ID, SPContext.Current.Site.SystemAccount.UserToken);
    • Avoid passing SharePoint objects between different security contexts (SPSite instances), with the exception of the SPUserToken used in the SPSite ctor. An SPUser object created from SPSite A cannot (reliably) be passed to SPSite B. This can be the source of obscure bugs in production that are difficult to reproduce in development. For example, an SPUser reference created from SPContext.Current.Site cannot reliably be used in an elevated site context, as the user reference may take on a different meaning in the alternate context.
    • Never use elevated privilege to bypass security-- always use it to work with security.
    • Restrict what assemblies can use elevated privilege by running in minimal trust, avoiding the GAC, and auditing any CAS policies deployed with vendor solutions.

    A better way to do perform system actions is to impersonate the SHAREPOINT\system account. Impersonation is a concept that is built into the object model, but is underutilized by developers.
    The SPSite object takes an SPUserToken object in its constructor in order to support impersonation. (This does require Impersonate="True" for the Microsoft.SharePoint.Security.SharePointPermission permission class). You can impersonate any user when creating the SPSite context-- so to get the system account, just use the magic system account "SHAREPOINT\system".
    Here's a code sample of SYSTEM ACCOUNT impersonation. The SYSTEM ACCOUNT uses the login name "SHAREPOINT\system" internally while it will use the process identity (usually that means the application pool identity, but it could be the service identity if a task was run as a timer job) when making external network calls. Note that the account is abstracted, and when a request comes into the system AS this account it will take on the identity of SYSTEM ACCOUNT.
    Here's the code sample. Grab a user object, and then grab the SPUserToken for impersonation:

    var user = SPContext.Current.Web.AllUsers[@"SHAREPOINT\SYSTEM"];
    var superToken = user.UserToken;
    using (var site = new SPSite(SPContext.Current.Web.Url, superToken))
    {
        /*This code runs under the security context of the SHAREPOINT\system*/
        /* for all objects accessed through the "site" reference. Note that it's a
    // different reference than SPContext.Current.Site.*/

        using(var elevatedWeb = site.OpenWeb())
        {
            /* Perform actions as SYSTEM here*/
        }
    }

    Because the thread identity hasn't changed, this will produce more stable code in most circumstances, although you should be aware that ONLY objects that are referenced from the elevated site context will run as system.


    Posted by admin on Monday, August 25, 2008 11:27 AM
    Permalink | Comments (1) | Post RSSRSS comment feed