Sunday, December 22, 2019

Download deployed WSP Solutions from SharePoint farm

Leave a Comment
While working with for a client, whom project previous vendor left in middle without proper documentation, project plan & updated source code. Only option left for me is to download deployed WSP Solutions from Production farm and go through deployed Dll through tools like ILSpy etc.

To download we used following powershell commands:

$farm=Get-SPFarm
$file=$farm.Solutions.Item("DEPLOYED_WSP_NAME.wsp").SolutionFile
$file.SaveAs("C:\SomeDownloadLocation\DEPLOYED_WSP_NAME.wsp")
Read More

The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered

Leave a Comment
While trying to run SharePoint powershell on vendor VM, found this issue: "

The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered"


Solution:

We need to run with domain account by which we setup SharePoint farm and run following command:

Add-SpShellAdmin -username Domain\username.

Above command set appropriate permission automatically and this can be verified by Get-SPShellAdmin
Read More

Sunday, August 25, 2019

Configure Gmail as SMTP for SharePoint 2016 server to relay messages

Leave a Comment
This blog post is about configuring gmail as smtp for SharePoint 2013/2016/2019 to relay email messages on behalf of SharePoint.

First of all we need to configure SMTP server on Windows server (Currently I am using Windows Server 2016 Standard)

If IIS Manager 6 feature/role isn't setup first we need to set it up from Add server roles & features.

Once configured, open IIS 6 Manager and right click on SMTP Virtual server and click properties:

Until we want SMTP server to use specific IP address, leave the setting as it is in General tab
Then click Access tab
Make sure by clicking Authentication button that anonymous access is selected
On Access tab click on connection button and select second option or choose first option with your server IP address added, then click OK.
On Access tab click on Relay and choose All except list below option as shown below
Then click on delivery tab, and choose Outbound security button and select Basic authentication and enter gmail credentials and check TLS encryption and click OK.
In the Outbound connection, enter 587 as TCP Port and click OK.
In the delivery tab click Advanced button and fully qualified domain name FQDN and smart host as smtp.gmail.com
Then login to gmail account which we are using as SMTP relay, click on My Account and then Sign in security  and select Allow less secure apps to ON position

Don't forget to update POP UP setting of gmail account

Although gmail SMTP as relay has been completed and can be verified by using a simple Powershell command/script as below:

Just to explain, here from address can be used as any address but email will always be come from your gmail smtp relay email address we used above.

In order to complete SharePoint outgoing email, in Centeral Admin of SharePoint, click System Settings and Outgoing email settings



Read More

Wednesday, August 7, 2019

SharePoint: How to verify current logged in user belong to which SharePoint Group

Leave a Comment
There was a scenario, we during our development cycle faced multiple time that we need to verify currently logged in user in SharePoint for its role or SharePoint Group. As based on role we have different business rules & business process automation. So following is server side code for verifying currently logged in user (either Active directory based or form based authtentication) belong to which SharePoint Group:

//Let user be authenticated first into SharePoint
SPClaimsUtility.AuthenticateFormsUser(
                       new Uri(SPContext.Current.Web.Url), username, password);                   
                       
                        SPUser spUser = SPContext.Current.Site.RootWeb.EnsureUser(SPContext.Current.Web.CurrentUser.LoginName);

                        //check logged in user belong to which SharePoint group/role
                        SPSecurity.RunWithElevatedPrivileges(delegate ()
                        {

                            //SPSite site = SPContext.Current.Site;
                            using (SPSite site = new SPSite(SPContext.Current.Web.Url))
                            {
                                using (SPWeb web = site.OpenWeb())
                                {                                   
                                    if(spUser!=null)
                                    {
                                        var userGroups = spUser.Groups;
                                        foreach (SPGroup group in userGroups)
                                        {
                                            if (group.Name.ToLower().Equals("role1"))
                                            {
                                                userGroup = "role1";
                                            }
                                            else if (group.Name.ToLower().Equals("role2"))
                                            {
                                                userGroup = "role2";
                                            }
                                            else if (group.Name.ToLower().Equals("role3"))
                                            {
                                                userGroup = "role3";
                                            }
                                        }
                                    }                                 
                                }
                            }
                        });
Read More

Monday, July 15, 2019

Which application pool id link with which worker process (w3wp.exe)

Leave a Comment
Often there are times when we need to debug our application by Debug-> attach to process option in visual studio. Here we need to figure out which application pool is currently linked with our application. So to figure out run following command:

C:\Windows\System32\inetsrv>appcmd list wp


Read More

Tuesday, June 11, 2019

How to enable Anonymous access for SharePoint 2010/2013/2016/2019 sites

Leave a Comment
In this post I will share my experience for making a SharePoint 2016 web application/site anonymous. The procedure is very much the same which we used to have for SharePoint 2010/2013 web application and exactly same approach need to be taken for SharePoint 2019 application.

Extending web application:

Well it depends on methodology and practices, but I used to extend current web application and apply anonymous access for extended application and used default site for admin purposes only. So following steps are needed to make a site anonymous.

Step 1:
As mentioned above we need to extend our current web application (if required). If extending of application isn't require, Step 1 can be skipped.



Step 2:
Select application and click on authentication provider and select zone which you need to make site anonymous. I choose internet zone as shown below




Step 3:
In Authentication provider, we checked "Enable Anonymous access" setting. Other setting can be chosen as per need example for crawling related to search NTLM based setting or kerberos or Role based authentication & authorization etc



Step 4:
Then click on web application and choose Anonymous policy. Here we can define authorization restriction based on specified zone (if we want it to assigned to user). For my case and for internet zone I choose No Policy


Step 5:
Then we need to go to extended site (if created) or sharepoint site and go to site settings & Site permissions. In my case I have variations enable, so I need to go to top level site settings under site collection administrator, as by default in variation site, site will redirect to root level variation. If you need to understand how variation or multilingual site creation work then it is in my another blogpost.

Under top level site settings under Users & Permissions section click on Site Permission and then choose anonymous access


This is all settings which is required for making a site anonymous and once visiting this site it serve as anonymous.





Read More

Monday, June 10, 2019

How to configure multilingual site: variation in SharePoint 2013/2016/2019

1 comment
In this post I will quickly walk through steps we used to perform while creating multilingual site in SharePoint 2016. Same steps need to be followed for SharePoint 2013 & SharePoint 2019.

Variation brief:

Variations feature is provided by Microsoft in SharePoint to provide & propagate multilingual content management through SharePoint application. In simple term variation is managed through labels (subsite for each language).

Step 1:

First of all install language pack by downloading it from Microsoft site. Once language pack is installed we will continue to Step 2.

Step 2:

Then under site settings at top level site, under Site Collection Administrator click on variation settings. Most of these setting are self-explanatory and can be changed late on based on customized requirements.



Step 3:

Here we are creating english as root site and choose locale as english as well. Also I choose top level site as source/target level variation.



Step 4:

In this step we would create other labels/variations for required multilingual sites e.g. arabic etc.

I used to allow both human & machine translation and i choose allow automatic update target variation pages

Since variation creation hierarchy is a timer job and if Arabic or other language hierarchy isn't created and we need to do it manually then we need to run it from SharePoint Central Admin -> Monitor -> Review Job Definitions under Time Jobs and click "Variation Create Hierarchy Job Definition" by selecting current web application




Read More