From dbe5055765538dfe8f41d059801ce74a5d9042fd Mon Sep 17 00:00:00 2001 From: aurnor <33629764+aurnor@users.noreply.github.com> Date: Thu, 27 Jun 2024 15:53:06 +0200 Subject: [PATCH] Upgrade to .NET Framework 4.8 and update dependencies Upgraded project to target .NET Framework 4.8. Updated package references to newer versions and added new package dependencies. Modified authentication flow in GraphUtils.cs to use interactive token acquisition. Made minor formatting and version updates in various files. --- README.md | 4 +- .../App.config | 98 ++++++++++- ...icrosoft.Internal.MSContactImporter.csproj | 166 ++++++++++++++++-- .../MsGraph/GraphUtils.cs | 11 +- .../Outlook/OutlookUtils.cs | 2 +- .../Properties/Resources.Designer.cs | 2 +- .../Properties/Settings.Designer.cs | 2 +- .../packages.config | 56 +++++- 8 files changed, 305 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 7911097..108eb1f 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ The program can: - add contacts : add contacts who are subordinates of the defined alias(es) / add members of the defined distribution list or security group - update contacts : it will update the information for the contacts previously imported -- delete duplicate : delete previously imported contacts which are not in the directory anymore +- delete orphans : delete previously imported contacts which are not in the directory anymore > /!\ All managed contacts are marked in the category "Ms Staff v2" and others contacts will remain untouched ## Compatibility -The program has been tested against Office 2016 *(32 bits and 64 bits)* and requires the minimum version of .Net framework 4.5.2 +The program has been tested against Office 2016 *(32 bits and 64 bits)* and requires the minimum version of .Net framework 4.8 ## Known issues and solution diff --git a/src/Microsoft.Internal.MSContactImporter/App.config b/src/Microsoft.Internal.MSContactImporter/App.config index 900c36c..8b6ee33 100644 --- a/src/Microsoft.Internal.MSContactImporter/App.config +++ b/src/Microsoft.Internal.MSContactImporter/App.config @@ -1,4 +1,4 @@ - + @@ -7,7 +7,7 @@
- + @@ -54,4 +54,96 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.Internal.MSContactImporter/Microsoft.Internal.MSContactImporter.csproj b/src/Microsoft.Internal.MSContactImporter/Microsoft.Internal.MSContactImporter.csproj index bc4dc98..fa63d99 100644 --- a/src/Microsoft.Internal.MSContactImporter/Microsoft.Internal.MSContactImporter.csproj +++ b/src/Microsoft.Internal.MSContactImporter/Microsoft.Internal.MSContactImporter.csproj @@ -9,7 +9,7 @@ Properties Microsoft.Internal.MSContactImporter MSContactImporter - v4.5.2 + v4.8 512 true false @@ -27,6 +27,9 @@ 1.0.0.%2a false true + + + AnyCPU @@ -56,32 +59,168 @@ app.ico - - ..\packages\log4net.2.0.12\lib\net45\log4net.dll + + ..\packages\Azure.Core.1.40.0\lib\net472\Azure.Core.dll - - ..\packages\Microsoft.Graph.1.9.0\lib\net45\Microsoft.Graph.dll + + ..\packages\log4net.2.0.17\lib\net45\log4net.dll - - ..\packages\Microsoft.Graph.Core.1.9.0\lib\net45\Microsoft.Graph.Core.dll + + ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll - - ..\packages\Microsoft.Identity.Client.1.1.2-preview0008\lib\net45\Microsoft.Identity.Client.dll + + ..\packages\Microsoft.Graph.5.56.0\lib\netstandard2.0\Microsoft.Graph.dll + + + ..\packages\Microsoft.Graph.Core.3.1.12\lib\net462\Microsoft.Graph.Core.dll + + + ..\packages\Microsoft.Identity.Client.4.61.3\lib\net462\Microsoft.Identity.Client.dll + + + ..\packages\Microsoft.Identity.Client.Extensions.Msal.4.61.3\lib\netstandard2.0\Microsoft.Identity.Client.Extensions.Msal.dll + + + ..\packages\Microsoft.IdentityModel.Abstractions.7.6.2\lib\net472\Microsoft.IdentityModel.Abstractions.dll + + + ..\packages\Microsoft.IdentityModel.JsonWebTokens.7.6.2\lib\net472\Microsoft.IdentityModel.JsonWebTokens.dll + + + ..\packages\Microsoft.IdentityModel.Logging.7.6.2\lib\net472\Microsoft.IdentityModel.Logging.dll + + + ..\packages\Microsoft.IdentityModel.Protocols.7.6.2\lib\net472\Microsoft.IdentityModel.Protocols.dll + + + ..\packages\Microsoft.IdentityModel.Protocols.OpenIdConnect.7.6.2\lib\net472\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll + + + ..\packages\Microsoft.IdentityModel.Tokens.7.6.2\lib\net472\Microsoft.IdentityModel.Tokens.dll + + + ..\packages\Microsoft.Kiota.Abstractions.1.9.6\lib\netstandard2.0\Microsoft.Kiota.Abstractions.dll + + + ..\packages\Microsoft.Kiota.Authentication.Azure.1.1.7\lib\netstandard2.0\Microsoft.Kiota.Authentication.Azure.dll + + + ..\packages\Microsoft.Kiota.Http.HttpClientLibrary.1.4.3\lib\net462\Microsoft.Kiota.Http.HttpClientLibrary.dll + + + ..\packages\Microsoft.Kiota.Serialization.Form.1.2.5\lib\netstandard2.0\Microsoft.Kiota.Serialization.Form.dll + + + ..\packages\Microsoft.Kiota.Serialization.Json.1.3.3\lib\netstandard2.0\Microsoft.Kiota.Serialization.Json.dll + + + ..\packages\Microsoft.Kiota.Serialization.Multipart.1.1.5\lib\netstandard2.0\Microsoft.Kiota.Serialization.Multipart.dll + + + ..\packages\Microsoft.Kiota.Serialization.Text.1.2.2\lib\netstandard2.0\Microsoft.Kiota.Serialization.Text.dll - ..\packages\Microsoft.Office.Interop.Outlook.15.0.4797.1003\lib\net20\Microsoft.Office.Interop.Outlook.dll + ..\packages\Microsoft.Office.Interop.Outlook.15.0.4797.1004\lib\net20\Microsoft.Office.Interop.Outlook.dll True - - ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll - True + + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Std.UriTemplate.1.0.2\lib\netstandard2.0\Std.UriTemplate.dll + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.ClientModel.1.0.0\lib\netstandard2.0\System.ClientModel.dll + + + + ..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.IdentityModel.Tokens.Jwt.7.6.2\lib\net472\System.IdentityModel.Tokens.Jwt.dll + + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + + + ..\packages\System.IO.FileSystem.AccessControl.5.0.0\lib\net461\System.IO.FileSystem.AccessControl.dll + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + ..\packages\System.Memory.Data.8.0.0\lib\net462\System.Memory.Data.dll + + + ..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll + True + True + + + ..\packages\System.Net.Http.WinHttpHandler.8.0.0\lib\net462\System.Net.Http.WinHttpHandler.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll + True + True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll + True + True + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.ProtectedData.8.0.0\lib\net462\System.Security.Cryptography.ProtectedData.dll + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + True + + + ..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll + + + ..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll + + + ..\packages\System.Text.Json.8.0.3\lib\net462\System.Text.Json.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + @@ -89,7 +228,6 @@ - diff --git a/src/Microsoft.Internal.MSContactImporter/MsGraph/GraphUtils.cs b/src/Microsoft.Internal.MSContactImporter/MsGraph/GraphUtils.cs index 2406315..3cfe879 100644 --- a/src/Microsoft.Internal.MSContactImporter/MsGraph/GraphUtils.cs +++ b/src/Microsoft.Internal.MSContactImporter/MsGraph/GraphUtils.cs @@ -16,7 +16,10 @@ internal class GraphUtils //Application name MSPhotoDownloader private static string ClientId = "3d53d92f-f208-4c15-8638-3d5c69661727"; - public static PublicClientApplication PublicClientApp = new PublicClientApplication(ClientId); + //public static PublicClientApplication PublicClientApp = new PublicClientApplication(ClientId); + IPublicClientApplication PublicClientApp = PublicClientApplicationBuilder.Create(ClientId).Build(); + + private AuthenticationResult authResult; public async Task SigninAsync() @@ -25,11 +28,7 @@ public async Task SigninAsync() try { - authResult = await PublicClientApp.AcquireTokenSilentAsync(_scopes, PublicClientApp.Users.FirstOrDefault()); - } - catch (MsalUiRequiredException) - { - authResult = await PublicClientApp.AcquireTokenAsync(_scopes); + authResult = await PublicClientApp.AcquireTokenInteractive(scopes: _scopes).ExecuteAsync(); } catch (Exception ex) { diff --git a/src/Microsoft.Internal.MSContactImporter/Outlook/OutlookUtils.cs b/src/Microsoft.Internal.MSContactImporter/Outlook/OutlookUtils.cs index 3a82d76..90ebe23 100644 --- a/src/Microsoft.Internal.MSContactImporter/Outlook/OutlookUtils.cs +++ b/src/Microsoft.Internal.MSContactImporter/Outlook/OutlookUtils.cs @@ -144,7 +144,7 @@ internal bool InsertOrUpdateContact(MSFTee msftee, GraphUtils graphUtils) try { string picturePath = graphUtils.GetPhotoForUserAsync(msftee).Result; - if (!string.IsNullOrEmpty(picturePath)) + if (!string.IsNullOrEmpty(picturePath)) contact.AddPicture(picturePath); //Not using async/await pattern to avoid changing all the rest of the calling code } catch { } //Simply ignoring the error, contact will have no picture diff --git a/src/Microsoft.Internal.MSContactImporter/Properties/Resources.Designer.cs b/src/Microsoft.Internal.MSContactImporter/Properties/Resources.Designer.cs index 07521ab..5432dfe 100644 --- a/src/Microsoft.Internal.MSContactImporter/Properties/Resources.Designer.cs +++ b/src/Microsoft.Internal.MSContactImporter/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Microsoft.Internal.MSContactImporter.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/Microsoft.Internal.MSContactImporter/Properties/Settings.Designer.cs b/src/Microsoft.Internal.MSContactImporter/Properties/Settings.Designer.cs index e88fe98..c1b0345 100644 --- a/src/Microsoft.Internal.MSContactImporter/Properties/Settings.Designer.cs +++ b/src/Microsoft.Internal.MSContactImporter/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace Microsoft.Internal.MSContactImporter.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.2.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/src/Microsoft.Internal.MSContactImporter/packages.config b/src/Microsoft.Internal.MSContactImporter/packages.config index 66b6f09..b7a84a9 100644 --- a/src/Microsoft.Internal.MSContactImporter/packages.config +++ b/src/Microsoft.Internal.MSContactImporter/packages.config @@ -1,11 +1,51 @@  - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file