About Me

My photo
a Dynamic and Energetic guy.....

Wednesday, September 14, 2011

SharePoint 2010 permission levels

              
Permission Levels
1.       Full
2.       High
3.       WSS_Medium
4.       Medium
5.       Low
6.       WSS_Minimal (Default security level that comes with SharePoint)
7.       Minimal
Things that we can do when do custom development
   1. Raise the trust level of the application
   2. GAC your assemblies (so that they run in full trust and get the permissions needed)
   3. Put the assemblies in to ‘Bin’ folder and create a custom policy file, refer it in web.config file

Create SharePoint search results using FullTextSqlQuery

            DataTable search = new DataTable();
            using (SPSite site = new SPSite(SPContext.Current.Web.Site.Url))
            {
                SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue();
                SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue("Search Service Application");

                FullTextSqlQuery query = new FullTextSqlQuery(searchProxy);

                query.QueryText = "SELECT FirstName,LastName ,AccountName,WorkPhone,UserName,PreferredName,AboutMe,NationalityP,NationalityS FROM SCOPE() WHERE \"Scope\"='People' ";
                query.ResultTypes = ResultType.RelevantResults;
                query.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
                query.KeywordInclusion = KeywordInclusion.AllKeywords;

                ResultTableCollection results = query.Execute();
                if (results.Count > 0)
                {
                    ResultTable relevant = results[ResultType.RelevantResults];
                    search.Load(relevant);

                    // serialize DataTable to XML
                    StringBuilder resultsXml = new StringBuilder();
                    using (StringWriter sw = new StringWriter(resultsXml))
                    {
                        search.WriteXml(sw);
                        sw.Flush();
                    }

                    // move XML to the XmlDataSource
                    XmlDataSource xds = new XmlDataSource();
                    xds.EnableCaching = false;
                    xds.Data = resultsXml.ToString();
                }
            }

Create SharePoint search results programatically

private void ComplexSearch()
        {
            SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue();
            SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue("Search_Service_CUSTOM");
            KeywordQuery keywordQuery = new KeywordQuery(searchProxy);
            string SearchScope = "PEOPLE";
            keywordQuery.HiddenConstraints = "scope:" + "\"" + SearchScope + "\"";

            keywordQuery.TrimDuplicates = true;
            keywordQuery.EnableStemming = true;
            keywordQuery.IgnoreAllNoiseQuery = true;
            keywordQuery.QueryText =  "SELECT AccountName,PreferredName,PictureUrl,WorkEmail,JobTitle,Department,InternalNumber,OfficeNumber,AboutMe,Responsibility,Skills,HitHighlightedSummary,InternalTelephone,OfficeNumber,AboutMe,Responsibility,Skills,HitHighlightedSummary,HitHighlightedProperties,CollapsingStatus,Path,FirstName,LastName FROM Scope() WHERE ('scope'='People')";


            keywordQuery.EnablePhonetic = true;           
            keywordQuery.ResultsProvider = SearchProvider.Default;
            keywordQuery.ResultTypes = ResultType.RelevantResults | ResultType.SpecialTermResults ;
            ResultTableCollection resultsTableCollection = keywordQuery.Execute();
            ResultTable searchResultsTable = resultsTableCollection[ResultType.RelevantResults];
            DataTable resultsDataTable = new DataTable();
            resultsDataTable.TableName = "Results";
            resultsDataTable.Load(searchResultsTable, LoadOption.OverwriteChanges);

            DataView view = new DataView(resultsDataTable);
            SearchGrid.DataSource = resultsDataTable;
            SearchGrid.DataBind();
        }

My Masters