SharePoint developers often need to manipulate the SharePoint or Active Directory login name programmatically. The short code samples here demonstrate how to convert back and forth between the claims format and the regular SharePoint login name.
CSharp
Active Directory user impersonation with C#
This article provides a managed wrapper for the LogonUser function of the Win32 API. It allows you to perform active directory user impersonation using C#. You just need to have the credentials of the user.
SharePoint user impersonation with C# [SSOM]
Very often, developers need to execute some code in the context of another user. This article explains how to do SharePoint user impersonation with C# using the Server-Side Object Model (SSOM).
Delete Folder With Read-Only Contents Using C#
To delete a folder and its contents using C# is not necessarily as easy and straightforward as you might think. It becomes tricky when one or more files are marked as read-only. Here’s a recursive helper method.
Iterating List Items In Batches With C# [Chunking]
There are lots of programming situations where it is necessary to break up a large amount of work into smaller more manageable pieces or chunks. The technique is known as “Chunking” and is frequently used when a huge list needs to be iterated in batches of say, 100 items at a time.
Add Event Receiver To Specific List Instance In SharePoint
When binding SharePoint event receivers to lists and libraries, the generic method involves using the ListTemplateId element. The problem with this method is that it adds the event receiver to all lists with a matching ListTemplateId. However, in many cases, we only want our event receivers attached to specific list instances. Here’s an explanation of how to dynamically add an event receiver to lists with specific names across an entire site and its sub sites using C#.