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

Wednesday, May 29, 2019

My journey for upgrading web applications from SharePoint 2013 to SharePoint 2016: Step by step

Leave a Comment
I know its probably a bit late for upgrading from SharePoint 2013 to SharePoint 2016 as it should be upgraded to 2019. However, 2019 SharePoint applications upgrade I will write later on. Recently did a client project upgrade from SharePoint 2013 to SharePoint 2016, so here is my journey & steps which I followed:

Step 1: As normal procedure create a new web application from SharePoint Central Admin
Step 2: From managed content databases, remove content database for web application for Step 1

Step 3: Restore SharePoint 2013 content database on Database server
Step 4: From same managed content database choose web application created in Step 1
Step 5: After mounting content DB, we need to run few powershell commands to verify warning, possible errors which may happened during upgrade process and these are following. However, I used to add wsp solutions in order to verify possible issues may happened for code compatibility:

Step 6: As discussed we need to run series of Powershell command, first of it is: 
Test-SPContentDatabase -Name <Content_DB_Name> -WebApplication <WebAppName>
Above command will test content db against web application for all customization done as per content db are also installed in farm (WSP which we did in Step 5)
For me it just generated few warning which would not stop this upgrade as shown below


Step 7: Next powershell command in this series is to mount content db against this web application: 
Mount-SPContentDatabase -Name “<Content_DB_Name>” -DatabaseServer “<DBAlias>” -WebApplication <WebAppName>
According to microsoft documentation this command this will attach content db to web applicatoin
For me it don't show any error as show below


Step 8: Then we need to test the mounted site as Test-SPSite site url. This command run some series of health check against mounted spsite, site collection & its contents
Again it dont give any error for me

Step 9: Repair-SPSite -identity siteurl  and this command will fix any issues that it finds. For my case didn't find much


Step 10: And lastly Upgrade-SPSite siteUrl -VersionUpgrade
This command will actually upgrade site collections associated with this web application to SharePoint 2016 mode










Read More

Tuesday, May 21, 2019

How to convert Windows Server 2016 Evaluation to Licensed version

Leave a Comment
Problem:

In previous blog post I have blogged about how to change SQL Server License. Similarly, the client now wants to upgrade/update its Windows Server 2016 Evaluation license.

Run winver.exe to verify current version:



Solution:

So to cut short discussion we switch to our old buddy Dism.exe, so on command prompt or power shell with elevated privileges we need to run following command:

dism /online /set-edition:ServerStandard /productkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /accepteula

After that just restart the server, and to verify the update has been successful:



Read More

Monday, May 20, 2019

SQL Server: Once Evaluation period has expired, How to activate SQL Server or change product key

Leave a Comment
Problem Statement:

For one of my client we used SQL Server 2016 Evaluation key which give 6 months time period to evaluate SQL Server and its features.

As per discussion with client, they will in the meantime do the procurement process (usually its bit lengthy, hectic & bureaucratic process in Middle East) to procure Enterprise License as per business need. However, in the meantime our project has completed and we moved on to next client with this dependency mentioned in project closure about upgrade of Evaluation license to Enterprise license. But as expected I got a call from my client manager about assistance in changing their Evaluation license. So thought to write a blog to refer for future needs.

So in order to change evaluation license specially when its expired and don't allow any services and not allow to start and event viewer showing following error:


Solution:

Go to SQL Server installation Center and click Maintenance and then choose Edition Upgrade


Then provide license key and click Upgrade

Read More

Wednesday, April 17, 2019

(Solved) .Net core web api project with vscode keep giving HTTPS endpoints can only be configured using KestrelServerOptions.Listen()

Leave a Comment
Problem:

While working for Angular project with .net core web api using Json web token for angular security, we might get exception in program.cs file of Web API of project developed in .net core

public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}


While debugging project in vscode to run web api we find following exception:

asp.net core web api System.InvalidOperationException: HTTPS endpoints can only be configured using KestrelServerOptions.Listen(). at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAddressAsync>d__7.MoveNext()


Solution:

We need to disable / Commented out / remove https: from applicationUrl in launchSettings.json

"ProjectApi": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
//"applicationUrl": "https://localhost:5001;http://localhost:5000",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}

The reason from .net core 2.1 and onward this launchSettings.json is include as template as we create .net core project. However, this wasn't happening prior to .net core 2.0 and previous versions.

So updating applicationUrl in launchSettings.json under Properties folder would do the trick and web api should start working as expected
Read More

Sunday, April 14, 2019

How routing works in Angular (Brief overview)

Leave a Comment

Following is brief pictorial illustration related to angular routing:






















1: If Url is changed either through router link or directly changed in address bar
2: It verifies if path exist & match in rotues.ts or routing related configuration file. It also check if routes require redirect as per configuration provided in routing file.
3: Also to check if there are process guard related to activate or deactivate  guard
4: To resolve data as per routes defined.
5: Activate component and nested components
6: Display templates and complete the routing cycles, defined in those components which become activated.

Read More

Thursday, March 21, 2019

Angular 2 Events/Hooks Lifecycle

Leave a Comment
Following are brief of Angular 2 and onward related events/hooks life cycle for basic illustration:



Lifecycle Events/ Hooks
 Description
1
ngOnChanges
Fires before ngOnInit & when dataBound property changes
2
ngOnInit
Fires at on component initialize and after ngOnChanges
3
ngDoCheck
Fires at every change detection cycles
4
ngAfterContentInit
Fires after inserting content [ngContent]
5
ngAfterContentChecked
Fires after every insert content check
6
ngAfterViewInit
Fires after initialize of component/nested component
7
ngAfterViewChecked
Fires after every check of component/nested component
8
ngOnDestroy
Fires before destroy of component/directive
Read More

Wednesday, March 20, 2019

Angular Application Execution Cycle Summary

Leave a Comment
I came across a question about what is execution cycle of angular application in summarize manner. So following illustration will help us better understanding the execution flow of angular app:


  • Main.ts runs first

  • Based on definition of Main.ts, it will load "app.module.ts" which actually define "AppModule"

  • For "AppComponent" defined in "app.module.ts", this will load "app.component.ts"

  • A custom HTML element "app-root" linked as selector in "app.component.ts"

  • This "app-root" is linked to custom tag defined in "index.html"
 


Read More

Angular/Ng command to run node server for testing app

Leave a Comment
While developing angular application through VS Code or any editor of choice, the command to run Nodejs server in order to test web application/ app in browser we need to run following command:

ng serve












This will compile angular application and deploy it on local Nodejs server mostly configured at http://localhost:4200/

Whenever we make any changes to any *.ts, index.html or css file & save it, this will recompile angular application and reload it in browser.



Read More

ng command to create new component

Leave a Comment
While using Angular 7.x if we need to create new component we use following command at terminal (I am using VS Code)

ng generate component "component name"

Above command will generate new component along with its folder under app with component name. Also it will add entry to app.module.ts file under import section & under NGModule section as well.

However, if we need to create new component without create a separate folder for component (can be used as nested component) then in terminal window first I need to get into path of component where I need to create nested component and then run following command:

ng generate component "component name" --flat

If, we need to create inline style and inline template for nested/component then we have to use following command:

ng generate component "component name" --flat -inline-style -inline-template 

Or we can use short keys for above command as :

ng g c "component name" --flat -is -it
Read More

Monday, March 18, 2019

The Angular Ecosystem

Leave a Comment
There has been lots of discussion going on related to Angular and its ecosystem. With the way changes & updates going on, this ecosystem or components on which angular ecosystem being rely it has been revolutionized as well.

Following is simple info graphic representation of Angular Ecosystem, which will help in understanding and learning angular framework to implement an enterprise level application:




Read More