Quality of life user experience improvements to SharePoint Online through the use of 301 redirects and Azure App Service

Originally posted on Lucian.Blog. Follow Lucian on Twitter, @LucianFrango.

***

This is the third time in the last year that I’ve had to setup a HTTP 301 redirect in Azure for a customer.Doing so improves the general quality of life experience for users accessing various Microsoft 365 services, like for example specific SharePoint Online team sites, or Exchange Online OWA.

With each implementation I turned to Azure App Service to deliver the functionality needed.… [Keep reading] “Quality of life user experience improvements to SharePoint Online through the use of 301 redirects and Azure App Service”

Query multiple object classes from AD using LDAP Query

Recently I had to make a query to the Active Directory to get the list of users and contacts. To achieve this, I used the LDAP query. See the following function:

 ///<summary>
/// Queries the Active Directory using LDAP
///</summary>
///<param name="entry">Directory entry</param>
///<param name="search">Directory searcher with properties to load and filters</param>
///<returns>A dictionary with ObjectGuid as the key</returns>
public static Dictionary<string, SearchResult> QueryLDAP(DirectoryEntry entry, DirectorySearcher search)
{
    entry.AuthenticationType = AuthenticationTypes.SecureSocketsLayer;
    entry.Path = ConfigurationManager.AppSettings["LDAP.URL"].ToString();
    entry.Username = ConfigurationManager.AppSettings["LDAP.Username"].ToString();
    entry.Password = ConfigurationManager.AppSettings["LDAP.Password"].ToString();
    /// Load any attributes you want to retrieve
    search.SearchRoot = entry;
    search.PropertiesToLoad.Add("name");
    search.PropertiesToLoad.Add("telephonenumber");
    search.PropertiesToLoad.Add("mobile");
    search.PropertiesToLoad.Add("mail");
    search.PropertiesToLoad.Add("title");
    search.PropertiesToLoad.Add("department");
    search.PropertiesToLoad.Add("objectguid");
    search.PropertiesToLoad.Add("sn");
    search.PropertiesToLoad.Add("userAccountControl");
    search.PropertiesToLoad.Add("userPrincipalName");
    search.PropertiesToLoad.Add("msexchhidefromaddresslists");
    search.PropertiesToLoad.Add("samaccountname");
    search.Filter = "(|(ObjectClass=user)(ObjectClass=contact))";
    search.SearchScope = SearchScope.Subtree;
    SearchResultCollection result = search.FindAll();
    Dictionary<string, SearchResult> dicResult = new
    Dictionary<string, SearchResult>();
    foreach (SearchResult profile in result)
    {
       if (profile.Properties["objectGUID"] != null && profile.Properties["objectGUID"].Count > 0)
         {
           Guid guid = new Guid((Byte[])profile.Properties["objectGUID"][0]);
           dicResult.Add(guid.ToString(), profile);
         }
     }
     result.Dispose();
     entry.Close();
     entry.Dispose();
    return dicResult;

}

What this function does is, it queries the Active Directory and returns all profiles (set by filter) in a dictionary object.[Keep reading] “Query multiple object classes from AD using LDAP Query”