Skip to main content

Fereshteh Shafaghi

Go Search
Home
  

Other Blogs
There are no items in this list.
Unexpected Error in sharepoint

I'v been searching for a solution to see stack errors sice I started developing in sharepoint and I found a post at

http://www.andrewconnell.com/blog/archive/2007/02/01/5935.aspx

with title Making sense of SharePoint errors ,

In web.config of yr sharepoint application find

<safemode Callstack="false"   ..   and change it to true, and set CustomErrors mode ="Off"

 

 

Form Field Control

To have standard form control there is a solution in MOSS 2007:

We created list named lookups , we therefore can create any type of column there and define rules for that column such as optional or mandatory form , forexample we wanted to have a control to show list of employees ,  to fulfill that purpose we did the following steps:

1)      Create a column named Employee

2)      Check  Business Data Column as its type

3)      Assign the related BDC to it

Then  in c# code we write sth like this bellow code to have our employee list:

FormField bdcEmployee = new FormField();

bdcEmployee.ControlMode = SPControlMode.New;

bdcEmployee.ListId = oList.ID;

bdcEmployee.FieldName = "Employee";{ Employee  is the name of that column in our lookups list}           
Repaire IIS – Error 2148073478

Error: The IIS Admin Service terminated with service-specific error 2148073478

Suddenly our portal server 2003 crashed  due to some problem  in our server room. We did not want to reinstall sharepoint 2003 again, We therefore find a solution at

http://blogs.iis.net/lprete/archive/2008/01/20/iis6-restoring-metabase-configuration-to-a-new-server.aspx

The  problem is that IIS use encryption key in folder C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys to decrypt passwords in file  MetaBase.xml which is located on C:\WINDOWS\system32\inetsrv\MetaBase.xml. So if you can get a copy of your Metabase.xml and then reinstall IIS you will have clean MetaBase, Then Replace your new sessionKey in old Metabase and delete all encrypted passwords  and replace your new metabase with this one.

Configuring Single Sign-on  in MOSS 2007 to connect to external web applications

We wanted to implement a solutions  which avoid users to reenter their users name for each application, there are some FBA web applications in our organization, we therefore decided to use SSO feature in MOSS.

 

To configure SSO you can refer to here  . In our case we used our farm admin user but you should notice that you can only use this  account  localy, otherwise you see the related links on manage SSO disabled.

 

To redirect username and password  to other web applications you need to define that mapping, To find that you can go to Central Administration > Operations > Manage Single Sign-On > Manage Account Information for an Enterprise Application Definition    You can map your Portal user to a user in your  destination web application here . Once you add a user  this service creates a row in dbo.SSO_Credentials in SSO Database .

To get the user informations you create in Manage account you can use this code:

public void GetCredentials(string ssoApp, out string username, out string password)

{

 

    //connect to default SSO provider

    ISsoProvider provider = SsoProviderFactory.GetSsoProvider();

    SsoCredentials creds;

    try

    {

        //get credentials for currently logged in user

        creds = provider.GetCredentials(ssoApp);

    }

    catch (SingleSignonCredsNotFoundException ex)

    {

        string msg = "User " + HttpContext.Current.User.Identity.Name;

        msg += " does not have credentials stored in the Single Sign On database";

        throw new Exception(msg, ex);

    }

 

    //convert credentials into a string

    IntPtr pUserName = IntPtr.Zero;

    IntPtr pPassword = IntPtr.Zero;

    try

    {

        //NOTE: After this has been converted to a String object, it remains in

        //memory until the garbage collector collects it.

        pUserName = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(creds.UserName);

        username = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(pUserName);

 

        pPassword = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(creds.Password);

        password = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(pPassword);

    }

    finally

    {

        // Free zero out and free the BSTR pointers.

        if (pUserName != IntPtr.Zero)

        {

            System.Runtime.InteropServices.Marshal.ZeroFreeBSTR(pUserName);

        }

 

        // Free zero out and free the BSTR pointers.

        if (pPassword != IntPtr.Zero)

        {

            System.Runtime.InteropServices.Marshal.ZeroFreeBSTR(pUserName);

        }

    }

}

 

After getting credentials you should render html code to redirect to your webapplication:

<HTML>

<body onload='document.login.submit();'>

<form name='login' id='login' method='post' action='http://localhost/login.aspx'>

<input type='hidden' name='txtUsername' id='txtUsername' value='testuser' />

<input type='hidden' name='txtPassword' id='txtPassword' value='password' />

</form>

</body>

</html>

For more details about above code refer to http://www.synergyonline.com/blog/blog-moss/Lists/Posts/Post.aspx?ID=49

 

Problem to show actions on  bdc list webpart
I have an ADF with specific Finder but my SSP was unable to make profile page and also for other actions which I added them in actions of my entity. My fault was that I did not specify my identifier in return parameter of my specific finder method.
 
<Parameter Direction="Return" Name="Return">
  <TypeDescriptor TypeName="BDC.PhonebookEntry,PhonesLobSystem" Name="Return">
        <TypeDescriptors>
              <TypeDescriptor TypeName="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" IdentifierName="ID" Name="ID" />
                </TypeDescriptors>
      </TypeDescriptor>
</Parameter>
Hide View all site Content from users
You can hide controls and links from ordinary users and make them visible for managers that has ManageWeb Permission:
 
<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="ManageWeb">
    <div class="ms-quicklaunchheader">
 
<SharePoint:SPLinkButton id="idNavLinkViewAll" runat="server" NavigateUrl="~site/_layouts/viewlsts.aspx" Text="<%$Resources:wss,quiklnch_allcontent%>" AccessKey="<%$Resources:wss,quiklnch_allcontent_AK%>"/></div>
   
 </SharePoint:SPSecurityTrimmedControl>
Search On Part of the properties of userprofile

When we search for people with part of their properties on Shareppoint site it will not give us the results because of the related webpart PeopleCoreResultsWebPart searches for exact match.There is a good post hereby Ishai Sagi  to find how to make a webpart to work.However if you have a look at source of Microsoft.SharePoint.Portal.WebControls.SearchResults you will find that there is no need to include this.QueryTemplateWherePart += @"OR CONTAINS(#WeightedProps, '""%__keywordinputnoboundaryquote__%*""')";

On OnInit of the code in the above link because by default it searches by part of the keyword you only need to include this bellow code to specify that this is a search reslt for people scope.

this.QueryTemplateWherePart += @"AND ""DAV:contentclass""='urn:content-class:SPSPeople'";

ListViewByQuery  Control

This Control is located on Microsoft.SharePoint.WebControls namespace, By this control you can define a query and pass it to this control to execute.It has a query property. You need to define the field which need to display and you where clause:

There is a negative point about this control, I can not find a way to make paging for it, How ever you can use this sample to see how this control is working:

ListViewByQuery view = new ListViewByQuery();

 

                SPWeb tweb = SPContext.Current.Web;

                string sortorder = string.Empty;

                if (this.Context.Request != null && this.Context.Request["SortField"] != null)

                {

                    sortorder = BuildSortOrder(this.Context.Request["SortField"],

                        (this.Context.Request["SortDir"] == "Asc" ? "true" : "false"));                  

                }

 

                SPSecurity.RunWithElevatedPrivileges(delegate()

                   {

 

                       SPSite site = new SPSite(tweb.Site.Url);

                       SPWeb web = site.OpenWeb();

                       SPList list = web.Lists["کد سرويس هاي شرکت"];

 

                       ViewToolBar toolbar = new ViewToolBar();

                       SPView webPartView = list.Views[ViewOfSourceList];                    

                       view.List = list;

                       view.List.AllowEveryoneViewItems = true;                      

                       SPQuery query = new SPQuery(view.List.DefaultView);

                       query.ViewFields = BuildFields(Fields);

                     

                       //query.ViewAttributes = "Scope=\"\"Recursive\"\"";

                       string strquery = string.Empty;

                       strquery = this._provider.Message;

 

 

                       string filter1 = strquery;

                       string filter2 = BuildFilter();

                       strquery = MergFilter(filter1, filter2);

                       if (!string.IsNullOrEmpty(strquery) && strquery.LastIndexOf("</Where>") <=0)

                           strquery = "<Where>" + strquery + "</Where>";

                       strquery += sortorder;

                       query.Query = strquery;

                      

                       query.RowLimit = 6;

                       view.Query = query;

                       web.AllowUnsafeUpdates = true;

                       view.List.AllowEveryoneViewItems = true;

                       view.List.Update();

                       view.DisableFilter = true;

                       web.AllowUnsafeUpdates = false;

                    

                      // view.

                       PagingButton pb = new PagingButton();

                       //pb.tex

                      

                      

 

                       EnsureChildControls();

                       view.RenderControl(writer);

                      

                       pb.RenderControl(writer);

                      

                       RenderChildren(writer);

 

                      

 

                   }

               );

Write back DataBase Using  BDC

To write back database you need to prepare Application Definition File (ADF)  and add Some Method of type  "GenericInvoker" and for Retreive data you need to have a Method of type "Finder".Here is sample of Finder Method :

<Method Name="SimpleSearch">

   <FilterDescriptors>

      <FilterDescriptor Type="Comparison" Name="SearchDescriptor" DefaultDisplayName="آرگومان جستجو">

        <Properties>

            <Property Name="Comparator" Type="System.String">Equals</Property>

         </Properties>

      </FilterDescriptor>

    </FilterDescriptors>

    <Parameters>

      <Parameter Direction="In" Name="searchArgument">

          <TypeDescriptor TypeName="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" AssociatedFilter="SearchDescriptor" Name="searchArgument" />

      </Parameter>

      <Parameter Direction="Return" Name="Return">

          <TypeDescriptor TypeName="BDC.PhonebookEntry[],PhoneBookLobSystem" IsCollection="true" Name="Return">

             <TypeDescriptors>

                <TypeDescriptor TypeName="BDC.PhonebookEntry,PhoneBookLobSystem" Name="Item">

                   <TypeDescriptors>

                      <TypeDescriptor TypeName="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="PhoneNo" />

                      <TypeDescriptor TypeName="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Empno" />

                   </TypeDescriptors>

                  </TypeDescriptor>

                </TypeDescriptors>

              </TypeDescriptor>

            </Parameter>

          </Parameters>

          <MethodInstances>

            <MethodInstance Type="Finder" ReturnParameterName="Return" ReturnTypeDescriptorName="Return" ReturnTypeDescriptorLevel="0" Name="PhoneBook_Finder_Instance" />

          </MethodInstances>

        </Method>

There are some important notes in ADF:

·         You must define Return parameter as last parameter

·         You can not pass null values to methods, in our case we used webservice the other alternative is to use stored procedure

To execute Methods you can use a code like the bellow example it is about filling controls from database:

NamedLobSystemDictionary lobSystems = ApplicationRegistry.GetLobSystems();

            LobSystem lobSystem = lobSystems[lobSystemName];

            NamedLobSystemInstanceDictionary lobInstances = lobSystem.GetLobSystemInstances();

            LobSystemInstance lobInstance = lobInstances[lobSystemInstanceName];

            Entity entityObject = lobInstance.GetEntities()[entityName];

            NamedMethodInstanceDictionary methodInstances = entityObject.GetMethodInstances();

            MethodInstance methInstance = methodInstances[selectmethodInstanceName];

            Object[] methodArgs = methInstance.GetMethod().CreateDefaultParameterInstances(methInstance);

Object[] methodArgs = methInstance.GetMethod().CreateDefaultParameterInstances(methInstance);

            methodArgs[0] = ObjectID;

            IEntityInstanceEnumerator c = (IEntityInstanceEnumerator)entityObject.Execute(methInstance, lobInstance, ref methodArgs);

             while (c.MoveNext())

            {

                IEntityInstance IE = c.Current;

               //You can Populate Controls here

                 (IE["YouFieldName"            }

Visual studio 2008 extension for wss 3

There are no new features, other than this works with Visual Studio 2008. You can get it from here.

 

1 - 10 Next

 ‭(Hidden)‬ Admin Links