Posts

Showing posts from September, 2023

Connect to Exchange Online PowerShell with Connect-ExchangeOnline cmdlet and a service principal with client secret

Image
Connecting to Azure with a service principal with client secret is quite simple - you can get the credentials and pass them to the Connect-AzAccount cmdlet and specify the -ServicePrincipal parameter.   $credential = Get-Credential Connect-AzAccount -Credential $credential -TenantId " your-tenant-identifier " -ServicePrincipal  Connecting to Exchange Online however is somewhat more problematic - there is no "ServicePrincipal" parameter and using the cmdlet with just a credential and organization shows the following error. The user is not recognized as a managed user, or a federated user.Azure AD was not able to identify the IdP that needs to process the user U/P: Wrong username It looks like Microsoft haven't implemented the ability to use client secrets as they're not as secure as certificates (and the Connect-ExchangeOnline cmdlet has good support for certficiates). Microsoft doesn't appear to have implemented any of their online services with a...

SOLVED: How to check if a ZIP file is encrypted in C#.NET using Xceed ZIP.NET

Image
If you would like to chekc whether a ZIP file is encrypted in C#.NET using Xceed ZIP.NET you can use the following code. As a ZIP file supports the ability to encrypt each individual file (rather than the ZIP archive itself) you need to check the contents of the ZIP file and see if the files inside it are encrypted. /// <summary> /// Determines whether any of the contents of the specified ZIP file is encrypted /// </summary> /// <param name=" filename "> The absolute path to the ZIP file to evaluate. </param> /// <returns> A System.Boolean value that indicates whether any of the contents of the specified ZIP file is encrypted. </returns> public static bool IsEncrypted(String filename) {      try      {           if (!File.Exists(filename)) { throw new FileNotFoundException(Resources.CompressionSupport.FileNotFoundException); }           AbstractFile z...

SOLVED: How to load a ZIP file from a byte[] array in C# using Xceed ZIP.NET

Image
If you want to load a ZIP file in C# using Xceed ZIP.NET from a byte[] array you can do so easily by creating a MemoryStream and from there you create a StreamFile which can be loaded into the ZipArchive class. using (MemoryStream stream = new MemoryStream(zipData)) {      AbstractFile zipFile = new StreamFile(stream);      ZipArchive zip = new ZipArchive(zipFile);      AbstractFile[] files = zip.GetFiles( true ); }  While you're here - Why not check out our  Group Policy Audit and Documentation Tool ?

The Group Policy Management Console XML and HTML reports missing information due to limitations in the GPMC

Image
The Group Policy Management console (GPMC) in Active Directory has a nice feature which allows you to generate reports in HTML and XML format of the settings in the Group Policy Object. The report is actually generated by the GPMC itself rather than the domain controller the tool is running against. This is somewhat problematic due to possible version differences between the tool and the Group Policy object settings. Also the report only contains as much information as the tool can interpret - whilst the coverage is generally very good Microsoft seem to have become complacent in later versions of Windows where new settings have been added to Group Policy but the GPMC has not been updated to convert these into the settings in the HTML and XML reports.  This is actually highlighted in the Windows Defender Firewall section where you may see the following: This rule might contain some elements that cannot be interpreted by the current version of GPMC reporting module Group Policy store...