Sep 222010

Get the preferred search center url from the MySite settings of your SSP

 

When creating some custom MySite code we wanted to link back to the searchcenter from my MySite but instead of using a webpart property we wanted to create our links the same way SharePoint does in the original MySite: with the “Preferred Search Center” location in the MySite Settings of your SSP. In the end it took me more time to find this property and a way to access it because it’s a non-public property so I thought it was worth a post seeing as I didn’t find anything else online for this.

 

//Get your current context (or the context of the SSP in question if that’s not the one your running in)

ServerContext current;

current = ServerContext.Current;

 

//Get the UserProfileApplication

object userProfileApplication = current.GetType().GetProperty("UserProfileApplication", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(current, null);

 

//Get the canonicalSearchCenterUrl

string preferredSearchCenterUrl = ((string)userProfileApplication.GetType().GetField("canonicalSearchCenterUrl", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(userProfileApplication));

 

Grtz,

Tom

Published: 9/22/2010  8:13 PM | 0  Comments | 0  Links to this post

Jun 142010

Application pool password “recovery” possibility removed from SharePoint 2010

 

As some of you may know, in SharePoint 2007 it was possible to get the username & password for the application pool identity by deploying a webpart with a small piece of code as shown in Tobias Zimmergren's post here. This post showed us the need for running a least-privileged installation in SharePoint 2007 because this password was stored as plain text.

 

So I thought I’d try this out for SharePoint 2010 and what do you know, it doesn’t work anymore. Microsoft clearly saw this “bug” and resolved it by making sure the app.Password method can’t be called directly in code. If you need the password I think you’ll still be able to get it but not as plain text to be shown for the whole world to see.

 

If anyone does find a way around this and it’s still a bug, feel free to comment!

 

Gr

Tom

Published: 6/14/2010  3:38 PM | 0  Comments | 0  Links to this post

May 052010

SharePoint outgoing mail to SharePoint incoming mail library

I was trying to submit an infopath form through infopath form services (browser) with an e-mail to an incoming mail library on a SharePoint in another domain. I noticed that the mail was appearing in the drop folder, and was beging deleted after a minute (TimerService) but it didn't get added to my library.


When i tried to send exactly the same mail from Outlook it worked like a charm. This problem gave me a couple of hours headache and then i found this Microsoft kb saying basicly it's not supported to prevent loops. So a mail coming from workflow / alert / form services is not allowed in incoming mails for a library.


Now the good news is that there is a solution to this which i found here .

Solution
1. copy Smtpreg.vbs into the c:\inetpub\AdminScripts - smtpreg is available to download from MS. (google it)
2. create a vbs file from the script below and copy it to the AdminScripts folder (I named mine wss)
3. run the following commands to register the script
cd c:\inetpub\adminscripts
cscript smtpreg.vbs /add 1 OnArrival DeleteMsg CDO.SS_SMTPOnArrivalSink "mail from=*"
cscript smtpreg.vbs /setprop 1 OnArrival DeleteMsg Sink ScriptName "c:\Inetpub\AdminScripts\wss.vbs"
4. This will now catch all mail on arrival and remove the offending header.
So after hours of searching i finally found a "hack" to succesfully get Infopath form service mails to get picked up by the SPTimerService and saved in my incoming mail library.
Hope this helps someone out there!


Gr
Tom

Published: 5/5/2010  3:22 PM | 0  Comments | 0  Links to this post

Apr 212010

Infopath form server - passing url parameter to a infopath form

 

I wanted to load a new infopath form into a Xmlformview webpart in Sharepoint, but at the same time pass a url queryparameter to the infopath form.
At first you might think that this can't be done without code behind on the infopath form but I found an easy way to do this based on an article (Steven Van De Craen) of a collegue of mine.
The methods are quit simple

  1. Make sure u get a url parameter in the publishing page by clicking a link (ex http://moss/pages/createdoc.aspx?parameter=23
  2. Create a new custom SharePoint webpart that extends the Microsoft.Office.InfoPath.Server.Controls.XmlFormView class.
  3. Add an eventhandler in the onInit of the webpart for this.initialise
  4. In the handler add code to change the XML nodes in the infopath doc (pass parameter to a hidden field or something).

public class XmlFormViewExtender : Microsoft.Office.InfoPath.Server.Controls.XmlFormView
{
private bool _error = false;
private string _xpath = null;
private string _param = null;
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.Category("My Property Group")]
[WebDisplayName("parameter")]
[WebDescription("parameter Property")]
public string Param
{
get
{
if (_param == null)
{_param = "par";
}
return _param;
}
set { _param = value; }
}
[Personalizable(PersonalizationScope.Shared)]
[WebBrowsable(true)]
[System.ComponentModel.Category("My Property Group")]
[WebDisplayName("XPath")]
[WebDescription("XPath Property")]
public string XPath
{get
{
if (_xpath == null)
{
_xpath = "/my:form/my:param";
}
return _xpath;
}
set { _xpath = value; }
}
protected override void OnInit(EventArgs e)
{
this.Initialize += new EventHandler(XmlFormViewExtender_Initialize);
base.OnInit(e);
}
protected void XmlFormViewExtender_Initialize(object sender, Microsoft.Office.InfoPath.Server.Controls.InitializeEventArgs e)
{
if (XmlForm != null)
{
string value = this.Page.Request.QueryString[Param];
XPathNavigator _xNavMain = this.XmlForm.MainDataSource.CreateNavigator();
XPathNavigator result = _xNavMain.SelectSingleNode(XPath, this.XmlForm.NamespaceManager);
result.SetValue(value);
}
}
I've also created 2 properties (Param, XPath) for the webpart that hold the name of the parameter it should get (querystring) and the Xpath where to place the value of this param.
So the result of this webpart is that the value of the url parameter par will be filled into the XML of the infopath form in "/my:form/my:param" and will show this data when rendering the form.

 

Hope this helps someone out!

Published: 4/21/2010  3:20 PM | 0  Comments | 0  Links to this post

Apr 062010

MOSS 2007 anonymous access + forms based authentication


We've also had some problems after this because when we went into a list / library we still got our login page while we had followed all the steps mentioned in the article.


Turns out the problem was that our site was based on a publishing site template.
The solution is to deactivate a feature for the site and turn anonymous authentication off and on again as mentioned in this kb : http://support.microsoft.com/kb/927082/en-us?spid=11373&sid=200

 

  • Click Start, click Run, type cmd in the Open box, and then click OK.
  • Type the following lines at the command prompt. Press ENTER after each line.
    cd /d %commonprogramfiles%\Microsoft Shared\Web Server Extensions\12\Bin
    stsadm -o deactivatefeature -url http://ServerName -filename ViewFormPagesLockDown\feature.xml
  • Type exit to exit the command prompt.

 

Note After you run this command-line tool against your site, you must toggle the Site Settings advanced permissions to turn off Anonymous access. Then, turn on Anonymous access again. You must do this for the command to take effect on content that exists in the site.

 

After this we could open the list with our anonymous user but when we tried creating a new list item (by clicking the new button we saw after setting the anonymous access permissions add for the list) we got the login screen again.

 

Solution: Check if your list doesn't have a lookup column to another list that does not have anonymous authentication turned on. If so grant anonymous "view" access on the lookup list.

Hope this helps you out!

Published: 4/6/2010  3:19 PM | 0  Comments | 0  Links to this post

Mar 252010

Reattaching SharePoint 2007 content databases

I had to reinstall and reconfigure a MOSS 2007 server after a corrupt installation.


Went I reattached the old content DB it showed no problems, and I could see the old site collections added to my web application.


But when i tried to surf to the url of the site collection I got a http 500 internal server error.
At first I thought I hadn't installed / configured the new IIS on the server correctly, or the version of the content DB and moss installation wasn't the same. But when i created a new site collection in the old content db it worked perfectly.


After hours of searching I came to the conclusion that the existising site collections were created in dutch, while my new installation did not contain the language packs.
So when in doubt and your not sure about the content your importing, try installing language packs for MOSS 2007...

Published: 3/25/2010  3:13 PM | 0  Comments | 0  Links to this post