A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Thursday, November 22, 2012

SharePoint 2013 - Setup DNS and use FQDN to access SharePoint sites


In this article, you will learn how to create alternate URL for your SharePoint 2013 site. By default, you can access SharePoint site by using machine name, for example, if your machine name is MYCOMPANY, you can access SharePoint site using URL http://mycompany (provided you have a site collection set up at that URL). Now, suppose you want to have a meaningful URL for your site, for example, www.mycompany.com OR if you have different departments in your company and you want each department to access their site using their own URL, for example, http://hr.mycompany.com, http://finance.mycompany.com ,  etc., this can be achieved by configuring DNS. My assumption is that you have admin rights on the machine and you can add DNS role and configure it. To read more about SharePoint 2013 machine configuration, wait for my upcoming book on SharePoint 2013. I am just trying to finish up some new chapters. I may not wait till all chapters are ready and may release machine configuration part separately so stay tuned to this blog. In the steps below, you will add Active Directory Domain Services and set up a FQDN.

1.       Go to All Programs > Administrative Tools  and click Server Manager.

2.       Click Roles and then click Add Roles link.

3.       Click Next and then select the second check box Active Directory Domain Services and click Next >. Click Next again and then click Install. Installation will start and will take approx. 10 minutes to complete (depending on your computer’s speed). Click Close once the installation has completed.

4.       Click Active Directory Domain Services link. You will see following warning message:

This server is not yet running as a domain controller. Run the Active Directory Domain Services Installation Wizard (dcpromo.exe).

Click the link in this message to install Active Directory Domain Services.

5.      Click Next. Click Next again. Select the second option Create a new domain in a new forest and click Next.

6.      Provide a FQDN, for example, sp2013.com and click Next. I will use walisystems.com as that is my main domain. You will see this domain in the screenshots in this section.

7.      Select Windows Server 2008 from the drop down and click Next.

8.      Keep DNS server checked and click Next.

9.      You will see a warning message. Select first option Yes, the computer will use dynamically assigned IP address (not recommended). if you don’t want to assign a static IP to your computer  and click Next. If you want to make the change, assign static IP and run the wizard again.

10.  Next you may see this error:

 


 



Click Yes.


11.  You will be presented with another screen. Keep default values and click Next.

12.  Enter password for Directory Services Restore Mode Administrator Mode and click Next.

13.   Review your selections and click Next. DNS Installation starts.

14.  Click Finish after the installation has completed.

15.  Click Restart Now button to restart your machine.

16.   Open Server Manager again. Expand Roles. Expand Active Directory Domain Services. Expand Active Directory Users and Computers. You will see your domain listed there.


 



17.   Now you have setup the domain services, you can use multiple URLs to access SharePoint sites. As mentioned earlier, one way to access your SharePoint site is to use the machine name in the URL, for example, http://sp2013 (sp2013 is the machine name). With domain setup on your server, you can now access same site using URL like http://sp2013.walisystems.com. Please note that walisystems.com is the FQDN that we used while setting up DNS.

 
In the next article, you will learn how to add multiple URLs for different departments and configure Alternate Access  Mappings in SharePoint.

 
If you liked this article or gained something out of it, then please leave feedback. Your feedback is of paramount importance to me. Thank you for reading.

SharePoint 2013 Alternate Access Mapping


Alternate Access  Mapping (AAM) is a feature that allows a website to use different URLs. This is usually needed when you have different zones, for example, one for the Intranet and another for an Extranet. I will not cover the network configuration part to setup an alternate URL in the DNS. I assume you already have an alternate URL and you just want to configure the AAM. If you want to read about DNS configuration and how to setup alternate URLs in the DNS, read my upcoming book on SharePoint 2013 (name not decided yet) or wait for another blog post that will explain the process of setting up DNS.

Assuming you have following two URLs, the process to configure AAM is easy.

1.       http://sp2013

2.       http://sp2013.server.com

 

1.       Open Central Admin Site and click Application Management.

2.       Under Web Applications, click Configure alternate access mappings.

3.       You will notice you already have http://sp2013 listed there in the Default zone. To add new URL in the Intranet zone, click Add Internet URLs.

4.       From the Alternate Access Mapping Collection drop down, select correct application that you want to use for the AAM setting and then add URL in the text box labeled URL protocol, host and port, for example, http://sp2013.server.com.  From the Zone dropdown, select Intranet.

5.       Click Save.
 


SharePoint 2013 Business Connectivity Services Login failed for user NTAUTHORITY IUSR


If you have created an external content type and are tryingto access it in a list and get AccessDenied, that is because you have not given permissions to the logged inuser to use that external content type. You can easily give permissions to thatuser or to all users in your site by going to central administration site andconfiguring business connectivity service. For exact steps on how to do it,read my following blog:

SharePoint 2013 Business Connectivity Service Access DeniedError: http://blog.walisystemsinc.com/2012/11/sharepoint-2013-business-connectivity.html

Some users get another very interesting error message afterthey have assigned permissions on the external content type. The error messageis:

Message from ExternalSystem: ‘Login failed for user ‘NT AUTHORITY\IUSR’.’.


 This error occurs because database does recognize thecredentials passed from SharePoint. Which database? Database that you areconnecting to in your external content type! It depends on you have setupapplication pool identity in SharePoint. If you are not using managed serviceaccount for your services, you are most likely to get this error. This is notlikely to occur in corporate environments but in home or test environmentswhere users use LOCAL SYSTEM OR NETWORK SERVICE in application pools,this error will occur. This is because NETWORKSERVICE translates to NTAUTHORITY\IUSR when credentials are passed from web server to databaseserver. IUSR is used when usercredentials are not available, for example, for anonymous users. To resolvethis problem, either change application pool identity or add NT AUTHORITY\IUSR to the database permissions.The first scenario is quite common. You can change application pool identity bygo to the web server and updating application pools or by logging intoSharePoint central admin site and going to ManageService Accounts. We will cover second scenario here, that is, to add IUSR to the database.

1.      Go to MicrosoftSQL Server Management Studio and connect to your database server.

2.      Expand Securitynode and right-click Logins node andselect New Login.



3.      In the LoginName, enter IUSR and click Search…. This will open a new searchbox. Enter IUSR in the object nameand click Check Names. Click OK.

4.      You will notice that Login Name has been populated with MACHINENAME\IUSR where MACHINENAMEis your machine name, for example, in the figure below, you see SP2013\IUSR. SP2013 is my machine name.


This is not what you want to add to the logins. Change MACHINENAME to NT AUTHORITY so Login Name shouldread NT AUTHORITY\IUSR. Click OK.

5.      Now you may think that the user has been addedand your external content type will work. Right? Wrong! You still have to mapuser to the database otherwise you will get following error on the list page(where you are trying to load external content type):

The query against thedatabase caused an error.



 



 
This error occurs, as I said, because user is not mapped tothe database yet.

6.      To map user to the database, right-click NT AUTHORITY\IUSR in Logins and select Properties.


 


7.      There are two ways to do this mapping. One wayis to add user to one of the server roles, for example,  serveradminor sysadmin. This will give userfull rights to all databases and thus you won’t have to do explicit mapping. Todo this, on the properties page, click ServerRoles and check sysadmin. Click OK. Obviously you would not want to dothis in real environment. So the other option is to map the user directly tothe database that has been used in the external content type.



To add user mapping, in LoginProperties, click User Mapping.Locate the database in the list and then check the box in the Map column. As soon as you check thebox, NT AUTHORITY\IUSER appears inthe User column. That’s it. Click OK to save the setting. By the way onthe same properties page, you can also assign database role membership to theuser for the database but that is not required.



Now, go back to the list page and reload it. You will seeresults from the external data source.

 




 

SharePoint 2013 Business Connectivity Services Access Denied Error


In SharePoint 2013, If you have setup Business Connectivity Services, or BCS for short, and now you are trying to access an external content type in a list but you get “Access denied by Business Data Connectivity”, here is you will solve it.

 


 This error occurs because the logged in user does not have permissions on the external content type that you had created. To resolve the issue go to central administration site and give permissions to specific users on the external content type.

1.       Open SharePoint Central Admin site.

2.       Click Application Management.

3.       In Service Applications section, click Manage service applications.

4.       Click Business Data Connectivity Service.

5.       You will see your external content type listed on this page. Select it (by checking the box) and click Set Object Permissions button in the ribbon.



 6.       This will open a dialog box. Enter username that you want to give permission to in the box and click Add. Select the added user in the box below and select permissions for that user by checking the boxes against the listed permissions. Depending on the type of user, you can select which permissions to give. For example, giving them Execute permission will let them see the results. If the user is admin type, then give them all the permissions. Lastly, check the box at the bottom to “propagate” permissions to all methods of the external content type. Click OK to save the settings.

 

 



 Also, if you want to give access to all users in the organization, add NT Authority\Authenticated Users in the box at the top and click Add and then assign desired permissions as described above. When you add authenticated users, you see All Users (windows) listed as one of the users.

 

 


Wednesday, November 21, 2012

Web Applicaton Not Found


You are developing in Visual Studio and your code access your local SharePoint server. On running the application, you get the following error:

 

 
Figure 1: The web application at XXX could not be found.

Error is as following:

The web application at http://server could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

If you are developing in Visual Studio 2010 and the program compiles without issues the only thing you should check is the “Platform target” option in Project settings. SharePoint 2010 is a 64-bit application. You should select x64 in the platform target. By default, x86 (32-bit) is selected. Your program will compile but you will not be able to access the SharePoint web application. Change it to x64 and it should work.

 


Turn off launcher service


All of a sudden your SharePoint stops working. You cannot even access the central admin site. Did you change the service account recently? Did you change the password of service account recently? Did you change the password in the application pools? Here are some suggestions how you can fix the problem?

1.       Recycle your app pools

2.       Reset IIS

3.       Check Logs: If SharePoint is not running then there will be nothing in the logs. You need to check Windows event log. Check the error message and take action accordingly.

 

Only event log can tell you the error that has caused SharePoint to stop working. For example, you will see a message like this:

The Office HTML Viewer Service could not be registered with Office HTML Load Balancing Service.

 

Error:  Unable to connect to the remote server

Now there can be different reasons for this service to fail. For example, if the incoming port (Firewall settings) has been shut down, you will get this error.  Open the port to resolve the issue. Then if service account password has been changed and not updated in the settings this error may occur. If for any reason you are unable to resolve the issue and you are sure (or not sure) that you are using load balancing service, you can turn off the services in the Windows “Services”.

 
Fig 1: Turn off document conversion launcher and load balancer services

After fixing this and other similar issues, your SharePoint should start working again.

Truncate WSS_Logging DB


One day you try to access your SharePoint site and notice that site does not load and instead throws an error. You investigate the error and find out that it has something to do with the WSS_Logging database. It is a common problem and I have blogged about it before as well. I just cannot find that blog post anymore (smiles). I have changed three or four blogs over the last couple of years. Anyway, getting back to the point. If you are facing this issue, truncate your WSS_Logging DB and you should be good to go.

1.       Open your SQL UI. Right click WSS_Logging DB and go to Reports > Disk Usage OR Reports > Standard Reports > Disk Usage.


Figure 1: Disk Usage

2.       In the disk usage report, expand the second node to see current disk usage. It should be full.


 


3.       Right-click WSS_Logging B and select “New Query” and paste the following script in the window and then hit F5 to execute it. NOTE: This script was copied from the following link:


Author is Jonathan Bainbridge.

Script:

·         DECLARE @TableName AS VARCHAR(MAX)
DECLARE table_cursor CURSOR
FOR
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND TABLE_NAME LIKE '%_Partition%'
OPEN table_cursor
FETCH NEXT FROM table_cursor INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
DECLARE @SQLText AS NVARCHAR(4000)

SET @SQLText = 'TRUNCATE TABLE ' + @TableName

EXEC sp_executeSQL @SQLText

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

 

Different people have written different scripts to truncate the table. This one is a tested solution and works perfectly.

4.       After executing the query, go back to the disk usage report and now you should see that the database is empty. Open your SharePoint site and it should work.