Skip to content

Commit

Permalink
- Updated Microsoft.IdentityModel.Clients.ActiveDirectory from 2.19 t…
Browse files Browse the repository at this point in the history
…o 3.13.8

- Cannot update Microsoft.Azure.ActiveDirectory.GraphClient from 2.1.0 to 2.1.1 because v2.1.1 is not strongly signed
- Improved logging
  • Loading branch information
Yvand committed Dec 6, 2016
1 parent b484ce2 commit d337360
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 158 deletions.
4 changes: 2 additions & 2 deletions AzureCP/AuthenticationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public static string GetTokenForApplication(string tenantName, string clientId,
AuthenticationContext authenticationContext = new AuthenticationContext(String.Format(Constants.AuthString, tenantName), false);
// Config for OAuth client credentials
ClientCredential clientCred = new ClientCredential(clientId, clientSecret);
AuthenticationResult authenticationResult = authenticationContext.AcquireToken(Constants.ResourceUrl, clientCred);
string token = authenticationResult.AccessToken;
Task<AuthenticationResult> authenticationResult = authenticationContext.AcquireTokenAsync(Constants.ResourceUrl, clientCred);
string token = authenticationResult.Result.AccessToken;
return token;
}

Expand Down
210 changes: 86 additions & 124 deletions AzureCP/AzureCP.cs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions AzureCP/AzureCP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.ActiveDirectory.GraphClient, Version=2.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Azure.ActiveDirectory.GraphClient.2.1.0\lib\portable-net4+sl5+win+wpa+wp8\Microsoft.Azure.ActiveDirectory.GraphClient.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -68,12 +68,12 @@
<HintPath>..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.19.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.19.208020213\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.13.8.999, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.13.8\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.19.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.19.208020213\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.13.8.999, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.13.8\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
8 changes: 4 additions & 4 deletions AzureCP/AzureCPConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static AzureCPConfig GetFromConfigDB()
}
catch (Exception ex)
{
AzureCP.LogToULS(String.Format("Error while retrieving SPPersistedObject {0}: {1}", Constants.AZURECPCONFIG_NAME, ex.Message), TraceSeverity.Unexpected, EventSeverity.Error, AzureCPLogging.Categories.Core);
AzureCPLogging.Log(String.Format("Error while retrieving SPPersistedObject {0}: {1}", Constants.AZURECPCONFIG_NAME, ex.Message), TraceSeverity.Unexpected, EventSeverity.Error, AzureCPLogging.Categories.Core);
}
return null;
}
Expand All @@ -108,7 +108,7 @@ public static AzureCPConfig ResetPersistedObject()
AzureCPConfig newPersistedObject = GetDefaultSettings(persistedObject);
newPersistedObject.Update();

AzureCP.LogToULS(
AzureCPLogging.Log(
String.Format("Claims list of PersistedObject {0} was successfully reset to default relationship table", Constants.AZURECPCONFIG_NAME),
TraceSeverity.High, EventSeverity.Information, AzureCPLogging.Categories.Core);
}
Expand All @@ -124,7 +124,7 @@ public static void ResetClaimsList()
persistedObject.AzureADObjects = GetDefaultAADClaimTypeList();
persistedObject.Update();

AzureCP.LogToULS(
AzureCPLogging.Log(
String.Format("Claims list of PersistedObject {0} was successfully reset to default relationship table", Constants.AZURECPCONFIG_NAME),
TraceSeverity.High, EventSeverity.Information, AzureCPLogging.Categories.Core);
}
Expand All @@ -150,7 +150,7 @@ public static AzureCPConfig CreatePersistedObject()
PersistedObject.AzureTenants = new List<AzureTenant>();
PersistedObject = GetDefaultSettings(PersistedObject);
PersistedObject.Update();
AzureCP.LogToULS(
AzureCPLogging.Log(
String.Format("Created PersistedObject {0} with Id {1}", PersistedObject.Name, PersistedObject.Id),
TraceSeverity.Medium, EventSeverity.Information, AzureCPLogging.Categories.Core);

Expand Down
111 changes: 106 additions & 5 deletions AzureCP/AzureCPLogging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.SharePoint.Administration;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace azurecp
Expand All @@ -17,30 +18,130 @@ public class AzureCPLogging : SPDiagnosticsServiceBase
public enum Categories
{
[CategoryName("Core"),
DefaultTraceSeverity(TraceSeverity.Medium),
//DefaultTraceSeverity(TraceSeverity.VerboseEx),
#if DEBUG
DefaultTraceSeverity(TraceSeverity.VerboseEx),
#else
DefaultTraceSeverity(TraceSeverity.Medium),
#endif
DefaultEventSeverity(EventSeverity.Error)]
Core,
[CategoryName("Configuration"),
DefaultTraceSeverity(TraceSeverity.Medium),
#if DEBUG
DefaultTraceSeverity(TraceSeverity.VerboseEx),
#else
DefaultTraceSeverity(TraceSeverity.Medium),
#endif
DefaultEventSeverity(EventSeverity.Error)]
Configuration,
[CategoryName("Lookup"),
#if DEBUG
DefaultTraceSeverity(TraceSeverity.VerboseEx),
#else
DefaultTraceSeverity(TraceSeverity.Medium),
#endif
DefaultEventSeverity(EventSeverity.Error)]
Lookup,
[CategoryName("Claims Picking"),
#if DEBUG
DefaultTraceSeverity(TraceSeverity.VerboseEx),
#else
DefaultTraceSeverity(TraceSeverity.Medium),
#endif
DefaultEventSeverity(EventSeverity.Error)]
Claims_Picking,
[CategoryName("Rehydration"),
#if DEBUG
DefaultTraceSeverity(TraceSeverity.VerboseEx),
#else
DefaultTraceSeverity(TraceSeverity.Medium),
#endif
DefaultEventSeverity(EventSeverity.Error)]
Rehydration,
[CategoryName("Claims Augmentation"),
#if DEBUG
DefaultTraceSeverity(TraceSeverity.VerboseEx),
#else
DefaultTraceSeverity(TraceSeverity.Medium),
#endif
DefaultEventSeverity(EventSeverity.Error)]
Claims_Augmentation,
[CategoryName("Rehydration"),
[CategoryName("Debug"),
#if DEBUG
DefaultTraceSeverity(TraceSeverity.VerboseEx),
#else
DefaultTraceSeverity(TraceSeverity.High),
#endif
DefaultEventSeverity(EventSeverity.Error)]
Debug,
[CategoryName("Custom"),
#if DEBUG
DefaultTraceSeverity(TraceSeverity.VerboseEx),
#else
DefaultTraceSeverity(TraceSeverity.Medium),
#endif
DefaultEventSeverity(EventSeverity.Error)]
Rehydration,
Custom,
}

public static void Log(string message, TraceSeverity traceSeverity, EventSeverity eventSeverity, AzureCPLogging.Categories category)
{
try
{
WriteTrace(category, traceSeverity, message);
//LdapcpLoggingService.WriteEvent(LdapcpLoggingService.Categories.LDAPCP, eventSeverity, message);
}
catch
{ // Don't want to do anything if logging goes wrong, just ignore and continue
}
}

public static void LogException(string ProviderInternalName, string faultyAction, AzureCPLogging.Categories category, Exception ex)
{
try
{
string message = "[{0}] Unexpected error {1}: {2}: {3}, Callstack: {4}";
if (ex is AggregateException)
{
var aggEx = ex as AggregateException;
foreach (var innerEx in aggEx.InnerExceptions)
{
if (innerEx.InnerException != null)
message = String.Format(message, ProviderInternalName, faultyAction, innerEx.InnerException.GetType().FullName, innerEx.InnerException.Message, innerEx.InnerException.StackTrace);
else
message = String.Format(message, ProviderInternalName, faultyAction, innerEx.GetType().FullName, innerEx.Message, innerEx.StackTrace);
WriteTrace(category, TraceSeverity.Unexpected, message);
}
}
else
{
if (ex.InnerException != null)
message = String.Format(message, ProviderInternalName, faultyAction, ex.InnerException.GetType().FullName, ex.InnerException.Message, ex.InnerException.StackTrace);
else
message = String.Format(message, ProviderInternalName, faultyAction, ex.GetType().FullName, ex.Message, ex.StackTrace);
WriteTrace(category, TraceSeverity.Unexpected, message);
}
}
catch
{ // Don't want to do anything if logging goes wrong, just ignore and continue
}
}

public static void LogDebug(string message)
{
try
{
TraceSeverity severity;
#if DEBUG
severity = TraceSeverity.High;
#else
severity = TraceSeverity.VerboseEx;
#endif
WriteTrace(AzureCPLogging.Categories.Debug, severity, message);
Debug.WriteLine(message);
}
catch
{ // Don't want to do anything if logging goes wrong, just ignore and continue
}
}

public static AzureCPLogging Local
Expand Down
2 changes: 1 addition & 1 deletion AzureCP/Features/AzureCP/AzureCP.feature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<feature xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.0.0.0" Id="d1817470-ca9f-4b0c-83c5-ea61f9b0660d" creator="Yvan Duhamel" description="Enables Azure AD Claims Provider - https://azurecp.codeplex.com/" featureId="d1817470-ca9f-4b0c-83c5-ea61f9b0660d" imageUrl="" receiverAssembly="$SharePoint.Project.AssemblyFullName$" receiverClass="$SharePoint.Type.39c10d12-2c7f-4148-bd81-2283a5ce4a27.FullName$" scope="Farm" solutionId="00000000-0000-0000-0000-000000000000" title="Azure AD Claims Provider" version="" deploymentPath="$SharePoint.Feature.FileNameWithoutExtension$" xmlns="http://schemas.microsoft.com/VisualStudio/2008/SharePointTools/FeatureModel" />
<feature xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.0.0.0" Id="d1817470-ca9f-4b0c-83c5-ea61f9b0660d" creator="Yvan Duhamel" description="Enables Azure AD Claims Provider - https://github.com/Yvand/AzureCP" featureId="d1817470-ca9f-4b0c-83c5-ea61f9b0660d" imageUrl="" receiverAssembly="$SharePoint.Project.AssemblyFullName$" receiverClass="$SharePoint.Type.39c10d12-2c7f-4148-bd81-2283a5ce4a27.FullName$" scope="Farm" solutionId="00000000-0000-0000-0000-000000000000" title="Azure AD Claims Provider" version="" deploymentPath="$SharePoint.Feature.FileNameWithoutExtension$" xmlns="http://schemas.microsoft.com/VisualStudio/2008/SharePointTools/FeatureModel" />
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<feature xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.0.0.0" Id="66d8f5d0-2a24-4e46-9ded-8db007e80307" creator="Yvan Duhamel" description="Adds links to central admin site to access AzureCP settings page - https://azurecp.codeplex.com/" featureId="66d8f5d0-2a24-4e46-9ded-8db007e80307" imageUrl="" solutionId="00000000-0000-0000-0000-000000000000" title="AzureCP Administration pages" version="" autoActivateInCentralAdmin="true" deploymentPath="$SharePoint.Feature.FileNameWithoutExtension$" xmlns="http://schemas.microsoft.com/VisualStudio/2008/SharePointTools/FeatureModel">
<feature xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.0.0.0" Id="66d8f5d0-2a24-4e46-9ded-8db007e80307" creator="Yvan Duhamel" description="Adds links to central admin site to access AzureCP settings page - https://github.com/Yvand/AzureCP" featureId="66d8f5d0-2a24-4e46-9ded-8db007e80307" imageUrl="" solutionId="00000000-0000-0000-0000-000000000000" title="AzureCP Administration pages" version="" autoActivateInCentralAdmin="true" deploymentPath="$SharePoint.Feature.FileNameWithoutExtension$" xmlns="http://schemas.microsoft.com/VisualStudio/2008/SharePointTools/FeatureModel">
<projectItems>
<projectItemReference itemId="c15a0bf3-126a-42e6-af6b-5880f2e9af42" />
</projectItems>
Expand Down
1 change: 1 addition & 0 deletions AzureCP/Package/Package.package
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<customAssembly location="Microsoft.Data.Services.Client.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Release\Microsoft.Data.Services.Client.dll" />
<customAssembly location="Microsoft.IdentityModel.Clients.ActiveDirectory.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Release\Microsoft.IdentityModel.Clients.ActiveDirectory.dll" />
<customAssembly location="System.Spatial.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Release\System.Spatial.dll" />
<customAssembly location="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Release\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll" />
</assemblies>
<features>
<featureReference itemId="70b104e2-19df-4cb1-9802-c98eaf14d84e" />
Expand Down
6 changes: 3 additions & 3 deletions AzureCP/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
[assembly: AssemblyTitle("AzureCP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Yvan Duhamel - [email protected]")]
[assembly: AssemblyCompany("Yvan Duhamel - [email protected]")]
[assembly: AssemblyProduct("AzureCP")]
[assembly: AssemblyCopyright("Copyright © 2014, Yvan Duhamel - [email protected]")]
[assembly: AssemblyCopyright("Copyright © 2016, Yvan Duhamel - [email protected]")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -34,5 +34,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("2.8")]
[assembly: AssemblyFileVersion("2.9")]

Loading

0 comments on commit d337360

Please sign in to comment.