poniedziałek, 23 września 2013

SharePoint user - when there are changes in AD

When some user data change in AD (e.g. last name) this change in most cases is not properly synchronized to SharePoint site collection.
The following Power Shell commands may help:

$user = get-spuser -Identity domain\username -Web http://server:port
Set-SPuser -Identity $user -SyncFromAD

Sadly it doesn't help in case an account name in AD has been changed. Then we have an orphaned user situation and the solution is to delete the account in SharePoint.
If it's only one site collection with couple of users, the quick way is to do it manually via Site collection - go to this page: http://sitecollection/_catalogs/users/simple.aspx

wtorek, 10 września 2013

Przeniesienie SharePoint Server 2013 na nową maszynę wirtualną

Na poprzedniej maszynie:


  1. Sporządzić listę baz danych używanych przez SharePoint server: Central Administration -> Upgrade and Migration -> Review database status
  2. Shutdown IIS
  3. Zatrzymać wszystkie windows services związane z SharePoint-em.

Przenosiny:


  1. Przenieść wszystkie bazy danych na nowy SQL server (Backup+Restore)
  2. Przenieść obraz maszyny wirtualnej z SharePoint server. Jeśli była to instalacja SharePoint+SQL Express na jednej maszynie, poprzedni punkt jest oczywiście zbędny. 

Na nowej maszynie:

  1. Uruchomić Sql Server Configuration Manager w celu zdefiniowania aliasów. Należy utworzyć identyczne aliasy dla SQL Native Client [VERSION] Configuration (dla 32 i 64 bitowego):
    - w polu Alias Name wpisać nazwę Sql Servera z poprzedniej maszyny,
    - skopiować nazwę do pola Server i zmodyfikować wpis o nazwę bieżącej maszyny.
  2. Aby aliasy działały, trzeba używać protokołu TCP/IP. W Sql Server Configuration Manager wejść do SQL Server Network Configuration>Protocols for SHAREPOINT. TCP/IP powinien być włączony a Shared Memory wyłączony.
  3. Wykonać restart maszyny
  4. Uruchomić sharepoint-owe windows services,  
  5. Odszukać windows service SQL Server Browser i uruchomić/upewnić się że działa.
  6. Sprawdzić czy SharePoint łączy się z właściwym serwerem bazy danych za pomocą procedury składowanej sp_who,
  7. Należy zmienić nazwę serwera ShaerPointa za pomocą programu stsadm.exe. Dla wersji 2013 znajduje się on w folderze: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\BIN.
    Polecenie zmiany nazwy serwera:
    stsadm -o renameserver -oldservername <YourOldServerName> -newservername <YourNewServerName>

czwartek, 23 maja 2013

Enable Session State in Sharepoint 2013

1. Run in PowerShell:
Enable-SPSessionStateService –DatabaseName "<your database name>"
or, if you don't mind guids in database names:
Enable-SPSessionStateService -DefaultProvision

2. Open web.config of the WebApplication where you want SessionState to be enabled and change line
<pages enableSessionState="false" (...)
to
<pages enableSessionState="true" (...)

3. Restart IIS

wtorek, 26 marca 2013

How to tune list view of style "Preview Pane". Part 2: no selection on page load

Another problem with the list or library view with style "Preview Pane" is that when the page loads, no item on the list is selected and as a result no field values are displayed in the table.
To correct this behaviour you need the help of javascript and jquery library.
Run SharePoint Designer and go to the view edition. You have to place these statements into the view code:

<scriptlink id="ScriptLink1" name="jquery.min.js" loadafterui="false" localizable="false" runat="server"></scriptlink>
<script type="text/javascript">
jQuery(document).ready(function () { $("div.ms-ppleft table tr td.ms-vb-title").first().trigger("onfocus"); })
</script>
The above code assumes that the jquery library file "jquery.min.js" is placed in folder C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS.

How to tune list view of style "Preview Pane". Part 1: duplicated "Name" field


When list's or library's view has style "Preview Pane", it shows all items' names in the list and the rest of the fields for the currently selected item is shown in the table. I don't like that the "Name" field gets duplicated in the list and in the table.

To correct this situation, run the SharePoint Designer and go to the view edition.
The inner name of the "Name" field is different for the list (LinkTitle) and for the library (LinkFilename). You can check the fields shown in the view looking for the <ViewFields> section in the code:

<ViewFields>
  <FieldRef Name="LinkFilename"/>
  <FieldRef Name="CustomField"/>
  <FieldRef Name="Modified"/>
</ViewFields>

First change the order of the fields so the "Name" field has the last position. You can do it in code or in Web GUI. 

Now find in code section that is responsible for drawing the table with fields:


<table class="ms-formtable" border="0" cellpadding="0" cellspacing="0" width="100%">
  <xsl:for-each select="ViewFields/FieldRef[not(@Explicit='TRUE')]">
    <tr>
      <td nowrap="nowrap" valign="top" width="190px"  class="ms-formlabel">
        <nobr>
          <xsl:value-of select="@DisplayName"/>
        </nobr>
      </td>
      <td valign="top" class="ms-formbody" width="400px" id="n{position()}{$WPQ}">
        <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
      </td>
    </tr>
  </xsl:for-each>
</table>

Add the xsl:if statement to eliminate the Name field from the table:

<table class="ms-formtable" border="0" cellpadding="0" cellspacing="0" width="100%">
  <xsl:for-each select="ViewFields/FieldRef[not(@Explicit='TRUE')]">
    <xsl:if test="@Name!='LinkFilename'">
      <tr>
        <td nowrap="nowrap" valign="top" width="190px"  class="ms-formlabel">
          <nobr>
            <xsl:value-of select="@DisplayName"/>
          </nobr>
        </td>
        <td valign="top" class="ms-formbody" width="400px" id="n{position()}{$WPQ}">
          <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
        </td>
      </tr>
    </xsl:if>
  </xsl:for-each>
</table>

poniedziałek, 4 lutego 2013

Migrating WebApplication from SP2010 to SP2013

1. Take the backup of web application content database on SharePoint 2010  from sql server using Sql Server Management Studio

2. On SharePoint 2013 create new web application. Pay attention that on SharePoint 2010 your application probably has classic-mode authentication, while on SharePoint 2013 the default is claims-based authentication. To create classic-mode web application in a SharePoint 2013, execute this command in PowerShell:
New-SPWebApplication –name "<WebAppName>"
–Port <PortNumber>
–ApplicationPool "<AppPoolName>"
–ApplicationPoolAccount (Get-SPManagedAccount "<Domain>\<AccountName>")

To use an existing application pool, provide only application pool name, without account.


3. Deploy all required farm solutions to the new web application

4. Remove content database from newly created web application in Central Administration > Manage Content Databases

5. Detach or delete the content database using Sql Server Management Studio

6. Now restore the backuped database.

7. Attach the restored content database to new web application using PowerShell:

Mount-SPContentDatabase -Name <DatabaseName> -DatabaseServer <DBServerName> -WebApplication <WebAppURL>