Showing posts with label Sharepoint. Show all posts
Showing posts with label Sharepoint. Show all posts

Wednesday, September 17, 2008

Windows Search Server (SharePoint): An unexpected error has occurred.

I have a sort of a „Love/Hate“ relationship with SharePoint. I like the product because I think it offers a lot you can do with it, but I hate it when it comes to troubleshooting.

This time, I have setup Windows Search Server 2008 and it works just perfectly on our site. I then gave the URL to somebody else from a different site and he only got An unexpected error has occurred. Great, here we go again.

The first thing is to turn on real error messages, not this stupid “Something went wrong, but I won’t tell you”.

To do so, open the web.config file for your site. For a default installation, this file will be located at C:\Inetpub\wwwroot\wss\VirtualDirectories\80. Open it in Notepad and search for customErrors mode="On". Replace it with customErrors mode="Off". To get more details, we will also turn on the call stack (in which procedure the error is actually happening). Search for CallStack=”false” and change it to CallStack="true" (this is in the SafeMode section).

Once we have done this, we were getting (somewhat) more detailed error messages:

Object reference not set to an instance of an object.

[NullReferenceException: Object reference not set to an instance of an object.] Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.OnLoad(EventArgs e) +94 System.Web.UI.Control.LoadRecursive() +65

On another machine we were getting this error:

Object reference not set to an instance of an object.

[NullReferenceException: Object reference not set to an instance of an object.] Microsoft.Office.Server.Administration.SqlSessionStateResolver.System.Web.IPartitionResolver.ResolvePartition(Object key) +77

The server was also now logs a lot of ASP.NET errors 1309 into the Application event log. Somehow I cam across a post from Chinmay Vartak showing the same error message (but for a different problem) and the steps he pointed out were the solution.

The problem was that on the remote site the name of the server was resolvable, but pointed to a wrong IP address. Although we were using a FQN (http://servername.site.acme.com instead of just http://servername) to access the server, internally WSS was not using the FQN but just the server name. So, all you need to do is to tell SharePoint to always use the FQN.

To do this, go to the Central Administration of the server and select Operations -> Alternate access mappings

Click on Edit Public URLs and change the entry for Default to be a FQN and click on Save.

In case you want to use SSL (https) also, you will need to create an entry for this also by using Add internal URLs and enter the https FQN URL for this server. When you have done this also, Alternate access mappings should show a list similar to this one:

Now all this stupid errors should be gone and everyone can access your server with either http or https.

Enjoy!

Thursday, April 10, 2008

Retrieving Windows SharePoint Services user access rights from the database

I case you ever need to know which access rights a given user has on your Windows SharePoint Services (WSS) site, you may find the following SQL scripts useful.


This SQL script (simply execute it against the database that has your WSS content) accepts either an email address (@search_email = 'John.Doe@acme.org') or the Windows login name (@search_account='ACME\JohnD').


If the given user is found, it will return three tables: The data of the user as WSS sees it, the groups to which the user belongs and finally to which sites the user has access to.




DECLARE @search_email varchar(100)
DECLARE @search_account varchar(100)

SET @search_email='John.Doe@acme.org
--SET @search_account='ACME\JohnD'


DECLARE @userid int

-- Retrieve user ID
IF (@search_account is null) BEGIN
select @userid=tp_ID from userinfo where tp_Email = @search_email
END ELSE BEGIN
select @userid=tp_ID from userinfo where tp_Login = @search_account
END

-- Show found user
SELECT '' as 'User Info',
tp_ID,tp_Login,tp_Title from userinfo where tp_ID=@userid

-- Show group membership
SELECT '' as 'Group membership',
ID,Title,Description from groups where id in
( SELECT groupid from groupmembership where memberid=@userid )
order by Title

-- Show Access rights
SELECT '' as 'Access rights',
Title, FulLURL from Webs where id in
( SELECT WebId FROM WebMembers WHERE (UserId = @userid) )
order by Title
GO