wtorek, 27 marca 2012

Access denied to "Configure service accounts"

I was completely surprised to get "Access denied" message when trying to open "Configure service accounts" option in Central Administration > Security. My account was in the farm administrators group, wasn't it!

But to be in the farm administrators group was not enough. To get access to the "Configure service accounts" I had to add my account to the local Administrators group on the machine running Sharepoint server.















That's all!

wtorek, 17 stycznia 2012

Quering tables residing on different servers and collation problem

If you want to query tables residing on another server first step is to link this server. You will do this in SQL Server Management Studio. Just expand the Server Objects node and you will see the Linked Servers node on which you can select "New Linked Server..." command.

Another option is to run these commands:

EXEC p_addlinkedserver    
  @server='<machine name>', 
  @srvproduct='',
  @provider='SQLOLEDB',
  @datasrc='<server name>',
  @catalog ='<database name>'
  
EXEC sp_addlinkedsrvlogin 
  '<server name>', 
  'false', 
   NULL, 
  '<login name>', 
  '<login password>'

Now you can query tables and views from the databases residing on the server you linked. They should be addressed this way:

[server].[database].[schema].[table]


It may happen that there are different collations in your host database and in linked database. As result, when linking tables from multiple servers in one query, you will get error:

Cannot resolve the collation conflict between "Polish_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.

My first guess was to change the collation. I choose the host database as it was still in the development phase.

ALTER DATABASE [database-name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE [database-name] COLLATE Polish_CI_AS
ALTER DATABASE [database-name] SET MULTI_USER


But it hasn't helped. The above commands changed the default collation of database and tables, but not the collation of existing columns.

Below you can find the code of the stored procedure generating ALTER TABLE statements for changing the columns collations all over the database.

But watch out! If there is any key or index on the column, the statement will fail. You have to drop the key, run the statement and recreate the key.

CREATE PROCEDURE [dbo].[ChangeCollation]
(
    @collation_name varchar(25)
)
AS
BEGIN
    SET NOCOUNT ON;
      
    DECLARE @TableName nvarchar(100)
    DECLARE @ColumnName nvarchar(100)
    DECLARE @ColumnType nvarChar(100)
    DECLARE @ColumnLengh float
    DECLARE @SQL nvarchar(1000)
    DECLARE @IsNullAble nvarchar(50)

    DECLARE cursor_tables CURSOR FOR
        select sysobjects.name from sysobjects where xtype='u'
             
    OPEN cursor_tables
    FETCH NEXT FROM cursor_tables INTO @TableName
    WHILE @@FETCH_STATUS = 0 BEGIN
      
        DECLARE cursor_columns CURSOR FOR
            select  syscolumns.name,
                    systypes.name as Type,
                    syscolumns.length,
                    syscolumns.isnullable
            from syscolumns
            inner join sysobjects on sysobjects.id=syscolumns.id
            inner join systypes on syscolumns.xtype = systypes.xtype
            where
                sysobjects.xtype='u' and
                (systypes.name='nvarchar' or systypes.name='varchar') and
                sysobjects.name=@TableName
             
        OPEN cursor_columns
        FETCH NEXT FROM cursor_columns 
            INTO @ColumnName, @ColumnType, @ColumnLengh, @IsNullAble
        
        WHILE @@FETCH_STATUS = 0 BEGIN
            IF (@IsNullAble='1')
                SET @IsNullAble = ' NULL'
            ELSE
                SET @IsNullAble = ' NOT NULL'
                    
            SET @SQL = 'ALTER TABLE ' + @TableName + ' ALTER COLUMN ' + @ColumnName + ' '
                     + @ColumnType + '(' + CAST(@ColumnLengh as NVARCHAR) + ') COLLATE '
                     + @collation_name + @IsNullAble

            PRINT(@SQL)
            --EXEC(@@SQL)

            FETCH NEXT FROM cursor_columns 
                INTO @ColumnName, @ColumnType, @ColumnLengh, @IsNullAble
        END
        CLOSE cursor_columns
        DEALLOCATE cursor_columns

        FETCH NEXT FROM cursor_tables INTO @TableName
    END
    CLOSE cursor_tables
    DEALLOCATE cursor_tables
END

GO


wtorek, 10 stycznia 2012

Tips for configuring search center


1. People searching does not work...
... while searching global scope ("All Sites") returns proper results.


Go to the "CA > Manage service applications > your Search Service Application > Content Sources". Make sure that one of the content sources being crawled (most probably "Local SharePoint sites") has the following entry in start addresses: "sps3://server-name" - where server-name is your web application URL.

You now have to check the Search Crawling Account permissions. Go to the "Security > Specify web application user policy" and select your web application. Make sure that crawling account has Full Read permission.

Search Crawling Account also needs to have permissions to the User Profile Service Application. To check it, open "Manage service applications", highlight User Profile Service Application and click on the Administrators button at the ribbon. The required permission is "Retrieve People Data for Search Crawlers".

Run full crawl on the content source containing "sps3://server-name" start address.

Now your people searching should work...

2. Searching within contextual scope does not work...
... while searching global scope ("All Sites") returns proper results.

Go to the Central Administration and check the alternate access mappings for the zone Default. Then go to the "Manage service applications > your Search Service Application > Content Sources". One of the content sources defined there (most probably "Local SharePoint sites") pertains web application where search in contextual scope is not working. Check the start addresses: the host URL must be the same as defined in alternate access mappings for the zone Default.

SharePoint creates the entry in the content source whenever you create a web application. But you must remember that changing  alternate access mappings can cause the URLs listed in content source stop matching and then your contextual searching stops working.

3. You want to have searching results from contextual scope displayed on the same, customizable page, as searching results from global scope.


That's pretty easy. Go to the Site Collection Administration settings and choose "Search settings".
In the "Site Collection Search Dropdown Mode" select mode that allows contextual scope, otherwise the next setting - "Site Collection Search Results Page" - will be disabled.
Now you have to enter address of the page that the searching result will be displayed on - preferably the search results page from your Search Center:


poniedziałek, 5 grudnia 2011

Jak zmienić nazwę bazy danych dla SharePoint Central Administration (7 kroków do wolności od GUID-ów)


1. Uruchom SharePoint 2010 Management Shell

2. Utwórz nową, pustą bazę danych dla aplikacji Central Administration:

New-SPContentDatabase -Name MOSS_207_AdminContent -WebApplication http://plglisrv207:10000

3. Odczytaj ID bazy danych z GUIDem. Następująca komenda zwróci informacje na temat obu baz danych: z GUIDem i nowej, utworzonej w poprzednim kroku:

Get-SPWebApplication –Identity http://plglisrv207:10000 | Get-SPContentDatabase

4. Przenieś site collections z bazy danych z GUIDem do nowej bazy danych. Do identyfikacji baz danych użyj ID odczytanych w poprzednim kroku:

Get-SPSite -ContentDatabase 4d46caff-7bb0-4a47-bedf-76fdb983dd0f | Move-SPSite -DestinationDatabase 87db4860-036e-4b3b-9540-905352893b09





5. Zgodnie z zaleceniem, uruchom IISRESET z linii poleceń.

6. Możesz zweryfikować wykonane operacje, uruchamiając Central Administration > Application Management > Manage Content Databases.

7. Najwyższy czas pozbyć się bazy danych z GUIDem:

Remove-SPContentDatabase –Identity 4d46caff-7bb0-4a47-bedf-76fdb983dd0f


A co z pozostałymi bazami danych, które Sharepoint tak szczodrze tworzy na serwerze, każda rzecz jasna z GUIDem w nazwie? Polecam artykuł na Technecie: Rename or move service application databases (SharePoint Server 2010).


środa, 23 listopada 2011

Smutne i ważne! Nie dla wszystkich szablonów stron można zastosować wielojęzykowy interfejs.

Pisze o tym Toni Frankola na swoim blogu: Not every SharePoint site template supports Multilingual UI (MUI)!

Lista szablonów stron, dla których jest to niemożliwe:


  • Basic Meeting Workspace
  • Blank Meeting Workspace
  • Decision Meeting Workspace
  • Social Meeting Workspace
  • Multipage Meeting Workspace
  • Blog

środa, 7 września 2011

Setting audience for Navigation Link can be tricky


Setting audience for Navigation Link seems to be pretty simple task. Yet one day I created dedicated SharePoint group for audience to global navigation item leading to other site collection and … it did not work.
SharePoint audience group had one member only: it was AD security group. It occurred that SharePoint audience group needed “Restricted Read” permission for the site containing navigation item. This was strange for me, because all the members of the AD security group had permissions even of higher level for this site. Well… another tricky SharePoint thing.
You can ask why not to grant permission directly to the AD group? Yes, I did it and it worked. But then I discovered that AD group was sort of unrecognizable for SharePoint:


And it still worked but to change the Navigation Link I had to specify the AD group again! 
It was annoying enough to select solution with SharePoint group rather. 

środa, 6 lipca 2011

CustomErrors mode

During SharePoint development you can get this kind of screen:


There are two places you should look for web.config file and correct the setting to
<customErrors mode="Off" />
to get meaningful details of your error displayed.

First one is obvious: your site's web config. Open the IIS Manager and explore your site in order to edit web.config file:

Second one had made me think for a second and then I decided to create this post. As I was working on application page which was deployed down in _layouts folder, I found there another web config file to be corrected:

Update for SharePoint 2013:

Expand _layouts folder and find the 15 subfolder: there you have to correct anothet web.config file!