January 30, 2017 / Kannan / 0 Comments
One of the consulting request I got was that an user should be able to sync files from a legacy system to O365 SharePoint Library. The issue was that the legacy system was old and all it could do was place a file in a particular folder.
The solution we could offer was the following.
- Configure a Windows mapped drive to point to a SharePoint library
- Configure the legacy system to place file into folder
This worked, but having a mapped drive was received as a security threat by the client’s security team.
But now thanks to the newly launched feature of syncing the SharePoint library files with OneDrive, this is easier.
Best part is, it supports both Windows & Mac.
Read more about it here
Image Source: Office Blog
January 11, 2017 / Kannan / 0 Comments
This post talks about a code which can copy new appointnments and meetings from one Microsoft Outlook calendar to another Microsoft Outlook calendar.
The code is capable of adding new, updating existing and deleting existing items.
One of the issues I was facing while working with my clients was, they had their own email system and they used to send appointment/meeting requests in those accounts for which I had a separate mail ID. For me it was becoming difficult to track all of them. So I was thinking about a way where all the calendar appointments/meetings across multiple clients get added to my own calendar.
While researching on this, came across a superb post Copy New Appointments to Another Calendar using VBA – Slipstick Systems and made use of it.
The code in the post works as is except for 2 things which I have listed below.
- The post uses default calendar as source and I wanted multiple calendar. For this instead of using “GetDefaultFolder” I used “GetFolderPath”. Do note that each instance of calendar required specific functions to be repeated. (I am planning to optimise this code so that the functions remain same but we can use multiple folders.)
- The post’s delete functionality was not working due to an issue where the delete function was comparing the GUID with starting character as “[“, which I had to comment out.
Following is the final code which worked for me.
Full credit goes to Diane Poremsky
'Macro to copy calendar items from current default calendar to another calendar
'Source: https://www.slipstick.com/developer/copy-new-appointments-to-another-calendar-using-vba/
Dim WithEvents curCal As Items
Dim WithEvents DeletedItems As Items
Dim newCalFolder As Outlook.folder
Private Sub Application_Startup()
Dim NS As Outlook.NameSpace
Set NS = Application.GetNamespace("MAPI")
' calendar to watch for new items
Set curCal = NS.GetDefaultFolder(olFolderCalendar).Items 'If you need to use a specific folder then use "NS.GetFolderPath("data-file-name\calendar").Items" and generally "data-file-name" is "user@domain.com"
' watch deleted folder
Set DeletedItems = NS.GetDefaultFolder(olFolderDeletedItems).Items 'If you need to use a specific folder then use "NS.GetFolderPath("data-file-name\Deleted Items").Items" and generally "data-file-name" is "user@domain.com"
' calendar moving copy to
Set newCalFolder = GetFolderPath("data-file-name\calendar")
Set NS = Nothing
End Sub
Private Sub curCal_ItemAdd(ByVal Item As Object)
Dim cAppt As AppointmentItem
Dim moveCal As AppointmentItem
' On Error Resume Next
'remove to make a copy of all items
If Item.BusyStatus = olBusy Then
Item.Body = Item.Body & "[" & GetGUID & "]"
Item.Save
Set cAppt = Application.CreateItem(olAppointmentItem)
With cAppt
.Subject = "Copied: " & Item.Subject
.Start = Item.Start
.Duration = Item.Duration
.Location = Item.Location
.Body = Item.Body
End With
' set the category after it's moved to force EAS to sync changes
Set moveCal = cAppt.Move(newCalFolder)
moveCal.Categories = "moved"
moveCal.Save
End If
End Sub
Private Sub curCal_ItemChange(ByVal Item As Object)
Dim cAppt As AppointmentItem
Dim objAppointment As AppointmentItem
On Error Resume Next
' use 2 + the length of the GUID
strBody = Right(Item.Body, 38)
For Each objAppointment In newCalFolder.Items
If InStr(1, objAppointment.Body, strBody) Then
Set cAppt = objAppointment
End If
Next
With cAppt
.Subject = "Copied: " & Item.Subject
.Start = Item.Start
.Duration = Item.Duration
.Location = Item.Location
.Body = Item.Body
.Save
End With
End Sub
Private Sub DeletedItems_ItemAdd(ByVal Item As Object)
' only apply to appointments
If Item.MessageClass <> "IPM.Appointment" Then Exit Sub
' if using a category on copied items, this may speed it up.
If Item.Categories = "moved" Then Exit Sub
Dim cAppt As AppointmentItem
Dim objAppointment As AppointmentItem
Dim strBody As String
On Error Resume Next
' use 2 + the length of the GUID
strBody = Right(Item.Body, 38)
'If Left(strBody, 1) <> "[" Then Exit Sub 'This particular line didn't work for me
For Each objAppointment In newCalFolder.Items
If InStr(1, objAppointment.Body, strBody) Then
Set cAppt = objAppointment
cAppt.Delete
End If
Next
End Sub
Public Function GetGUID() As String
GetGUID = Mid$(CreateObject("Scriptlet.TypeLib").GUID, 2, 36)
End Function
Function GetFolderPath(ByVal FolderPath As String) As Outlook.folder
Dim oFolder As Outlook.folder
Dim FoldersArray As Variant
Dim i As Integer
On Error GoTo GetFolderPath_Error
If Left(FolderPath, 2) = "\\" Then
FolderPath = Right(FolderPath, Len(FolderPath) - 2)
End If
'Convert folderpath to array
FoldersArray = Split(FolderPath, "\")
Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
If Not oFolder Is Nothing Then
For i = 1 To UBound(FoldersArray, 1)
Dim SubFolders As Outlook.Folders
Set SubFolders = oFolder.Folders
Set oFolder = SubFolders.Item(FoldersArray(i))
If oFolder Is Nothing Then
Set GetFolderPath = Nothing
End If
Next
End If
'Return the oFolder
Set GetFolderPath = oFolder
Exit Function
GetFolderPath_Error:
Set GetFolderPath = Nothing
Exit Function
End Function
August 23, 2016 / Kannan / 0 Comments
Following are the features which are not available in SharePoint 2013 Workflow.
- Actions
- Stop Workflow
- Capture a Version of the Document Set
- Send Document Set to Repository
- Set Content Approval Status for the Document Set
- Start Document Set Approval Process
- Declare Record
- Set Content Approval Status
- Undeclare Record
- Add List Item
- Inherit List Item Parent Permissions
- Remove List Item Permissions
- Replace List Item Permissions
- Lookup Manager of a User
- Assign a Form to a Group
- Assign a To-Do Item
- Collect Data from a User
- Start Approval Process
- Start Custom Task Process
- Start Feedback Process
- Copy List Item (SharePoint Designer 2013 supports only the document-copying action.)
- Conditions
- If current item field equals value
- Check list item permission levels
- Check list item permissions
- Steps
- Data sources
- Other features
- Visio integration
- Association Column
- Content Type Association for reusable workflow
- ‘Require Manage List/Web Permission’ feature for list/site workflow
- Globally reusable workflow type
- Workflow visualization option
Source: https://msdn.microsoft.com/en-us/library/jj728659.aspx
July 11, 2016 / Kannan / 0 Comments
In SharePoint 2013 search results, the icon for a file type like .msg, .txt shows up as .html icon.
In SharePoint 2010 this was overcome by mapping the icon file type in DocIcon.xml at WFE Servers.
But now since access to WFE servers are restricted in on-prem environment and no access in O-365 environment, the only solution available is to do the following.
- Edit the existing display template (I use custom display template with results shown in table and following is based on that) or create a new template for existing for the following located at (SiteCollection/All Files/_catalogs/masterpage/Display Templates/Search) accessible by using SharePoint Designer.
- xxxSearchTableResults.html
- xxxSearchTableItem.html
- Add the following codes and it should show correct icons.
Search Results Display Template:
<div style="width:15px;display:table-cell;text-align:left;font-weight:bold;padding: 5px 0px 4px 10px;">
</div>
Search Item Display Template:
<div style="min-width:16px;max-width:16px;display: table-cell;white-space:nowrap;overflow:hidden;-ms-text-overflow:ellipsis;-o-text-overflow:ellipsis;text-overflow:ellipsis;">
<!--#_
var extObj = new Object();
extObj["FileExtension"] = ctx.CurrentItem.FileExtension;
var iconUrl = SP.Utilities.HttpUtility.htmlEncode(Srch.U.ensureAllowedProtocol(Srch.U.getIconUrlByFileExtension(extObj, null)));
if(ctx.CurrentItem.IsContainer)
iconUrl = "/_layouts/15/images/icdocset.gif";
if(ctx.CurrentItem.FileExtension === "msg")
iconUrl = "/_layouts/15/images/icmsg.gif";
//console.log(ctx.CurrentItem.FileExtension);
_#-->
<img id="_#= $htmlEncode(id + Srch.U.Ids.icon) =#_" onload="this.style.display='inline'" src='_#= iconUrl =#_' />
</div>
Notes:
ctx.CurrentItem.FileExtension always return the file extension name which seems to match with the file name in the /_layouts/15/images/ folder.
For example msg = icmsg.gif or icmsg.png
Once done, the search results will show-up as following
March 30, 2016 / Kannan / 0 Comments
SharePoint Online Authentication
The following is the interaction between
- Client Computer
- Office 365
- Azure Active Directory (Azure AD)
- On premise Active Directory Federation Service (AD FS) (if available)
Notes:
- The customer can use either On Premise AD FS or any identity provider or they can use Azure AD
- The root Federation Authentication (rtFA) cookie is used across all of SharePoint Online. When a user visits a new top level site or another company’s page, the rtFA cookie is used to authenticate them silently without a prompt. When a user signs out of SharePoint Online, all SharePoint Online cookies are deleted.
Authentication Process
- User does anonymous request to secured O365 SharePoint Webpage (SharePoint.com)
- The SharePoint then requests the default identity provider or Azure AD to authenticate the user
- Azure AD then requests the user to provide credentials i.e email and password
- Azure AD then decides based on the email id, which identity provider to use, either itself or on prem AD FS
- User types in the credentials and sends back to AD FS using the client computer
- The on-prem AD FS or Azure AD then validates the credentials
- If on-prem AD FS is the provider, then it provides an auth token back to Azure AD post validating the user
- If Azure AD is the provider, then it generates the auth token
- In both the cases, Azure AD generates an auth token, stores it in client computer and redirects user back to SharePoint online
- O365 SharePoint server then validates this auth token with Azure AD
- O365 SharePoint then creates root Federation Authentication (rtFA) cookie and Fedauth cookie to client computer
- This rtFA cookie is used by the computer for subsequent requests
For more information visit https://support.office.com/en-us/article/SharePoint-Online-authentication-77965e8d-48ad-47bd-a656-57f17d6d1cc7?ui=en-US&rs=en-US&ad=US
March 30, 2016 / Kannan / 0 Comments
SharePoint 2013 – SAML Based Authentication
The following is the interaction between
- Client Computer
- SharePoint Server
- Active Directory Federation Service (AD FS)
- Active Directory Domain Service (AD DS)
Notes:
- AD FS & SAML Claims are not required if AD DS is the provider in which the forest and domains trust each other
- AD FS must trust the AD DS for which the AD FS is issuing the SAML security tokens
- Here the trust might be implicit as the AD FS is the member of AD DS domain and hence trusts the domain controllers
- AD FS must also trust the SharePoint locations
- Hence AD FS is configured with SharePoint’s web application URLs as relying parties
- SharePoint server also must trust the AD FS’s SAML token.
- This trust is obtained via a signed certificate which the AD FS has and it signs the tokens with this certificate
- The SharePoint server is also configured with the public portion of the above mentioned signed certificate which AD FS uses and SharePoint trust those signed tokens using this public portion
The SAML Based Authentication Process
- User does anonymous request to secured SharePoint Webpage
- SharePoint redirects the user to AD FS’s login page for user to enter credentials
- User types in the credentials and sends back to AD FS using the client computer
- The AD FS server then validates the credentials with AD DS
- Once user is validated, the AD FS then creates a SAML token, signs and send it back to client computer
- The client computer now sends a new request to SharePoint server now with SAML token provided by AD FS
- SharePoint then creates a claims based security token using Security Token Service and this claims is based on the claims which it found in SAML token which the AD FS has sent to client computer
- Then SharePoint stores this security token with Distributed Cache Service on the farm
- SharePoint server then generates and send the federated auth cookie back to client computer
- The fed auth cookie has encryped key or index to security token
- This fed auth cookie is used by the computer for subsequent requests
The following Video will explain the Forms based authentication in SharePoint 2013. This video is part of the Authentication overview for SharePoint 2013 article located at https://technet.microsoft.com/en-us/library/jj219571.aspx
For more information on SharePoint Claims check out more articles at http://social.technet.microsoft.com/wiki/contents/articles/14214.sharepoint-2013-claims-based-authentication.aspx
March 30, 2016 / Kannan / 0 Comments
SharePoint 2013 Authentication – Forms Based
The following is the interaction between
- Client Computer
- SharePoint Server
- ASP.NET Membership provider
The Form Based Claims Authentication Process
- User does anonymous request to secured SharePoint Webpage
- SharePoint responds with form based login page
- User types in the credentials and sends back using the client computer
- SharePoint server then validates the credentials with membership provider
- SharePoint server then queries the roles provider for user’s associated roles
- This becomes the role claims for user’s account
- SharePoint then creates a claims based security token using Security Token Service
- Then SharePoint stores this security token with Distributed Cache Service on the farm
- SharePoint server then generates and sends the federated auth cookie back to client computer
- The fed auth cookie has encrypted key or index to security token
- This fed auth cookie is used by the computer for subsequent requests
The following Video will explain the Forms based authentication in SharePoint 2013. This video is part of the Authentication overview for SharePoint 2013 article located at https://technet.microsoft.com/en-us/library/jj219571.aspx
For more information on SharePoint Claims check out more articles at http://social.technet.microsoft.com/wiki/contents/articles/14214.sharepoint-2013-claims-based-authentication.aspx
March 30, 2016 / Kannan / 0 Comments
SharePoint 2013 – Windows Claims Authentication
The following is the interaction between
- Client Computer
- SharePoint Server
- Active Directory Domain Service
The Windows Claims Authentication Process
- User does anonymous request to secured SharePoint Webpage
- SharePoint requests back Windows Credentials (It can be a NTLM or Kerberos or basic)
- If user is in intranet zone, the browser sends back the logged in credentials to SharePoint, else user is prompted for credentials
- For both the cases the browser send back the credentials to SharePoint
- SharePoint then validates this credentials with Active Directory Domain Services (AD DS)
- AD DS then responds back to SharePoint with Windows Security Token
- SharePoint then checks, to which security groups the user belongs in AD DS
- SharePoint then creates a claims based security token using Security Token Service
- Then SharePoint stores this security token with Distributed Cache Service on the farm
- The IIS Server in SharePoint server then send the auth code to the user’s computer
- The client computer then uses this auth code for subsequent requests
The following Video will explain the Windows claims authentication in SharePoint 2013. This video is part of the Authentication overview for SharePoint 2013 article located at https://technet.microsoft.com/en-us/library/jj219571.aspx
For more information on SharePoint Claims check out more articles at http://social.technet.microsoft.com/wiki/contents/articles/14214.sharepoint-2013-claims-based-authentication.aspx
March 22, 2016 / Kannan / 0 Comments
When we try to execute a custom java script code in SharePoint content editor web part, it may not work. The reason behind is that, there might be a conflict occurring during load.
Microsoft provides ways to launch your function after full page load and following is one of the method.
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("LaunchCustomCode");
LaunchCustomCode = function() {
ExecuteOrDelayUntilScriptLoaded(MyCode, "sp.js");
}
MyCode = function() {
console.log('My Code Start');
alert('MyCode Called');
console.log('My Code Finish');
}
</script>
March 10, 2016 / Kannan / 0 Comments
While working on designing display template for drop down based refiners in SharePoint Search there was a requirement to show counts along with refiners in refiners list.
Following is the change which I made in the refiner’s display template.
Actual code
<option value='_#= onChangeOrClick =#_'>_#= $htmlEncode(refinementName) =#_</option>
Updated Code
<option value='_#= onChangeOrClick =#_'>_#= $htmlEncode(refinementName) =#_ (_#= refinementCount =#_)</option>