Category: Microsoft
Category Archives: Microsoft
Search from specific sharepoint site or folder
Is it possible to use copilot to search info from specific sharepoint site or folder? i tried to give the link to the sharepoint site but it doesn’t seem to be working.
Is it possible to use copilot to search info from specific sharepoint site or folder? i tried to give the link to the sharepoint site but it doesn’t seem to be working. Read More
Problem with some external guests access in Teams using MFA
We have some guest users, from different Home tenants, that have problems logging in to our tenant with MFA when using Edge web browser.
It works fine when they are using InPrivate in Edge, another device or another web browser.
When we check their settings in our Entra everything looks correct. We have not changed any policies or settings and it is not all the guest user from the same Home tenant the have this issue, for most of the guest users from the same Home tenants it works fine accessing our tenant with MFA while a few guest users from the same company/ Home tenant have this issue.
It is almost as if there is a clash between their home tenant AAD user, Microsoft Edge, and the guest user in our AAD.
Does anyone have some recommendations och solutions to this issue?
We have some guest users, from different Home tenants, that have problems logging in to our tenant with MFA when using Edge web browser. It works fine when they are using InPrivate in Edge, another device or another web browser. When we check their settings in our Entra everything looks correct. We have not changed any policies or settings and it is not all the guest user from the same Home tenant the have this issue, for most of the guest users from the same Home tenants it works fine accessing our tenant with MFA while a few guest users from the same company/ Home tenant have this issue. It is almost as if there is a clash between their home tenant AAD user, Microsoft Edge, and the guest user in our AAD. Does anyone have some recommendations och solutions to this issue? Read More
Microsoft Copilot in Azure Series – Copilot Access Management
Hello folks!
Today, we’re diving into Microsoft Copilot in Azure. It’s like having a super-smart assistant in the cloud!
It’s an AI-powered tool that’s all about making your life easier when you’re working with Azure, when you’re navigating the Azure portal, or using the Azure mobile app.
Now, keep in mind, at the time of recording this, Copilot in Azure is still in preview. That means it’s like a sneak peek, and there are some extra terms you have to check out before you jump in.
This Copilot in Azure can be a real lifesaver. It knows a ton about Azure’s services and resources, it also has access to all the information in Azure Resource Graph.
It’s like having a cheat sheet for the cloud. You can ask it questions about your environment, and it’ll give you answers tailored to your own Azure resources, and your level of access.
That means that Microsoft Copilot in Azure will only report on the resources that you have access to. It can only take the actions that you have permission to perform, and it requires confirmation before making changes to your environment.
It complies with all existing access management rules and protections such as:
1- Azure role-based access control (Azure RBAC),
2- Privileged Identity Management,
3- Azure Policy,
4- and resource locks.
You can chat with Copilot right in the Azure portal or on the go with the Azure mobile app. It’s like texting with a friend who can do some of your homework for you. It’ll answer questions, run queries, and even perform tasks for you, all while keeping your organization’s policies in check.
Oh, to use Microsoft Copilot in Azure you might need to have a chat with your network or security admins about a WebSocket connections to https://directline.botframework.com .
It’s required for Copilot in Azure to work.
Now, Let’s dive into controlling the Access to Microsoft Copilot in Azure. By default, everyone in your tenant gets to play with Copilot in Azure. But, as the Global Administrator, you’ve got the power to manage access. Want to give specific users or groups a sneak peek? No problem! the video below shows you how to control access.
Remember, Copilot in Azure only helps you with the stuff you’re already allowed to touch. So, if you’ve already got access to certain data and resources, “Cool, let’s get to work!” But if it’s locked away from you, or you don’t have rights, Copilot respects that – no sneaking in or anything. It’s all about keeping things above board.
And that’s a wrap on this episode of ITOpsTalk “Using Microsoft Copilot in Azure”! Stay tuned to this channel for more episodes and updates
Catch you in the cloud!
Cheers!
Pierre
Microsoft Tech Community – Latest Blogs –Read More
Using Keycloak with Azure AD to integrate AKS Cluster authentication process
Introduction
Integrating Azure Kubernetes Service (AKS) with Keycloak through Azure Active Directory (Azure AD) as an intermediary leverages Azure AD’s support for OpenID Connect (OIDC) to handle authentication and authorization. This integration enhances security, streamlines user management, and simplifies the authentication process for users accessing the AKS cluster.
Use case
The integration of AKS with Keycloak using Azure AD is highly applicable in all these industries and beyond that prioritize security, scalability, and efficient user management, making it a best practice for organizations leveraging cloud-based Kubernetes environments.
Financial Services: Securely manage and authenticate thousands of users accessing sensitive financial data and applications hosted on Kubernetes clusters.
Healthcare: Protect patient data and ensure compliance with healthcare regulations while providing medical staff secure access to applications.
E-commerce: Manage a large user base accessing e-commerce platforms and ensure secure transactions and user data protection.
Technology and Software Development: Provide developers with secure access to development environments and resources hosted on Kubernetes clusters.
Education: Manage access to educational resources and applications for students, faculty, and staff in a secure manner.
Figure 1: Similar use case architecture.
Concept
To make this integration possible and effective you should have a clear understanding of the following components, the concept of using Azure AD as an intermediary, and the pre-requisites.
Understanding the Key Components
What is AKS?
Azure Kubernetes Service (AKS) is a managed Kubernetes service that simplifies deploying, managing, and operating Kubernetes clusters in the cloud.
What is Keycloak
Keycloak is an open-source identity and access management solution that provides features like single sign-on (SSO), identity brokering, and user federation.
What is Azure AD?
Azure Active Directory (Azure AD/Microsoft Entra ID) is Microsoft’s cloud-based identity and access management service, which helps users access external resources like Microsoft 365, the Azure portal, and thousands of other SaaS applications.
Overview of OIDC
OpenID Connect (OIDC) is an identity layer built on top of the OAuth 2.0 protocol, allowing clients to verify the identity of end-users based on the authentication performed by an authorization server.
Why Use Azure AD as an Intermediary?
Using Azure AD as an intermediary offers several benefits:
Enhanced Security: Leverages Azure AD’s robust security features.
Simplified Management: Centralizes authentication and authorization.
Seamless Integration: Provides easy integration with Azure services and applications.
Pre-requisites for Integration
Before starting the integration process, ensure you have:
Azure AD: Set up and configured with necessary permissions.
Keycloak: Configured with a realm ready to be integrated.
AKS Cluster: Either existing or a plan to create a new one with Azure AD integration.
Figure 2: Mian concept
According to the image shown in Figure 2: Main concept, the authentication processes taken place in this concept is Azure Active Directory (Azure AD/Microsoft Entra ID) at the center, and from the right Azure Kubernetes Service requested an authentication and Azure AD will perform OIDC Token Exchange to Keycloak at the left, then Keycloak will perform validation and revert back to Azure AD while, Azure AD respond back to AKS.
Hands-on (Technical Steps)
More technical in these steps and processes, you will find step-by-step guide for seamless Integration.
Register Keycloak as an Application in Azure AD.
Create an App Registration in Azure AD:
Navigate to Azure AD and create a new app registration.
Figure 3: Register Keycloak as an Application in Azure AD -1
Figure 4: Register Keycloak as an Application in Azure AD -2
Save the Client ID and Client Secret from Azure AD. This information will be needed later in Keycloak.
Obtain Client ID and Client Secret
After the registration is complete, go to the app’s overview page and copy the “Application (client) ID”.
Navigate to “Certificates & secrets” and create a new client secret. Copy the value of the client secret as it will not be shown again.
Figure 5: Register Keycloak as an Application in Azure AD -3
Configure API Permissions:
Go to “API permissions” and add the required Microsoft Graph API permissions. Typically, you need `User.Read` and `openid`, `profile`, and `email` permissions.
Figure 6: Register Keycloak as an Application in Azure AD -4
Figure 7: Register Keycloak as an Application in Azure AD -5
On click Add a permission, the above similar pane will be displayed as shown and you will click on Add permission. Then, after Add permission, you will have similar configuration to the below image.
Figure 8: Register Keycloak as an Application in Azure AD -6
Configure Keycloak to Use Azure AD
Set Up Keycloak:
https://www.keycloak.org/downloads
https://quay.io/repository/keycloak/keycloak
Log in to the Keycloak admin console.
Select the realm you want to configure or create a new realm.
Figure 9: Configure Keycloak to use Azure AD
Add Azure AD as an Identity Provider:
In the left menu, go to “Identity Providers”.
Click “Add provider” and select “OpenID Connect v1.0”.
Fill in the details:
Alias: A friendly name for the provider (e.g., AzureAD).
Display Name: A display name for the login button.
Authorization URL: `https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/authorize`
Token URL: `https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token`
Client ID: The Application (client) ID obtained from Azure AD.
Client Secret: The client secret obtained from Azure AD.
Save the configuration.
Import OIDC Metadata:
Go to the Azure AD app registration overview and find the “OpenID Connect metadata document” URL.
Figure 10: Configure Keycloak: In Keycloak, use this URL to import the metadata automatically, which fills out most of the configuration fields.
Integrate AKS with Azure AD
Enable Azure AD Integration When Creating AKS Cluster:
Use the following Azure CLI command to create an AKS cluster with Azure AD integration
az aks create
–resource-group myResourceGroup
–name myAKSCluster
–node-count 1
–enable-aad
–aad-admin-group-object-ids <admin-group-object-id>
–enable-oidc-issuer
–oidc-issuer-url “https://<keycloak-server>/auth/realms/<realm>”
Replace the placeholders with actual values:
`myResourceGroup`: The resource group name.
`myAKSCluster`: The AKS cluster name.
`admin-group-object-id`: The object ID of the Azure AD group that will have admin rights.
`oidc-issuer-url`: The URL of the Keycloak OIDC issuer.
Update Existing AKS Cluster:
If you already have an existing AKS cluster, use the following command to enable Azure AD integration:
az aks update
–resource-group myResourceGroup
–name myAKSCluster
–enable-aad
–aad-server-app-id <server-app-id>
–aad-server-app-secret <server-app-secret>
–aad-client-app-id <client-app-id>
–aad-tenant-id <tenant-id>
Outcome
The benefits of successful integration are not limited to the followings:
Streamlined User Management: Centralized user management through Azure AD.
Enhanced Security: Leverages Azure AD’s security features to protect your AKS cluster.
Simplify Security: Using Azure AD’s security features and Keycloak settings to simplifies the authentication process for users
Conclusion
We saw in this article how integrating AKS with Keycloak using Azure AD as an intermediary provides a robust and secure authentication solution. In addition, to the above steps, you can use `kubectl` to log into the AKS cluster test the integration, redirecting to the Azure AD login page, and after successful authentication, you should be redirected back to Keycloak if configured correctly. Verify that users have the appropriate roles and permissions in both Azure AD and Keycloak to access the AKS cluster. For troubleshooting, ensure the Client ID, Secret, and URLs are correct, and verify all required permissions and alignment of Keycloak and Azure AD settings and use HTTPS for all communications and regularly review and update access controls and permissions for security. Maintaining the system by keeping all components updated and implementing monitoring tools to track the health and performance of the integration and also, advanced configurations include adjusting claims in Keycloak to meet specific requirements and configuring group memberships according to organizational structure which will be in the next article. By following the steps outlined in this article, you can ensure a seamless and efficient integration process to simplify and enhance app security.
Microsoft Tech Community – Latest Blogs –Read More
Projector for LINQ
Hi,
I would like to share simple projector system, that is I believe a great improvement for LINQ:
using AutoMapper;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace ANeT.SharedData.Projection
{
/// <summary>
/// Base class for any Projector. This design pattern is able to protect input IQueryable for single SQL generation
/// while for IEnumerable allowing to use single query definition by internally representing it as IQueryable.
/// Fill internal method is used to chaining extension modules to final collection (adjusting current collection with new joins, conditions, …).
/// </summary>
/// <typeparam name=”P”>Factory Type</typeparam>
/// <typeparam name=”E”>Entity Type</typeparam>
public abstract class Projector<P, E>
where P : Projector<P, E>, new()
{
bool providersChecked = false;
IQueryProvider? originalProvider = null;
IQueryable<E> collection = null!;
protected IQueryable<E> Collection => collection;
protected Projector()
{ } // Constructor should be hidden so that internal system is safe.
/// <summary>
/// Factory of this Projector. Accepting any input collection,
/// however for IQueryable it is maintaining a single SQL generation.
/// IEnumerable input is internally represented as IQueryable.
/// </summary>
/// <typeparam name=”C”></typeparam>
/// <param name=”collection”></param>
/// <returns>Instance P</returns>
public static P Create<C>(C collection)
where C : IEnumerable<E>
{
P instance = new P();
if (collection is IQueryable<E> queryable)
{
instance.originalProvider = queryable.Provider;
instance.collection = queryable;
}
else
{
instance.collection = collection.AsQueryable();
}
return instance;
}
/// <summary>
/// Chaining method to follow with next Projector,
/// which one must follow the same entity type.
/// </summary>
/// <typeparam name=”C”>Factory Type</typeparam>
/// <returns>Instance C</returns>
public C Chain<C>()
where C : Projector<C, E>, new()
{
C instance = new C();
instance.originalProvider = this.originalProvider;
instance.collection = this.collection;
return instance;
}
/// <summary>
/// This method should be used at begin of any collection extension.
/// It is enforcing Provider rule on any join collection. (Protecting final collection from cross-context mixup.)
/// </summary>
/// <param name=”collections”>Checked collections</param>
/// <exception cref=”InvalidOperationException”></exception>
protected void CheckProviders(params object[] collections)
{
if (originalProvider == null)
{
return;
}
foreach (object collection in collections)
{
if (collection is IQueryable queryable && queryable.Provider != originalProvider)
{
throw new InvalidOperationException(“Chain of querying was broken.”);
}
}
providersChecked = true;
}
/// <summary>
/// Fill current Projector IQueryable with new altered version.
/// For Projector collection that was IQueryable at the input, it enforces Provider compatibility.
/// (Which is requiring programmers to call CheckProviders beforehand.)
/// </summary>
/// <typeparam name=”C”>Collection Type</typeparam>
/// <param name=”collection”>New collection</param>
/// <exception cref=”InvalidOperationException”></exception>
protected void Fill<C>(C collection)
where C : IEnumerable<E>
{
if (originalProvider != null &&
(!providersChecked || collection is not IQueryable<E> queryable || queryable.Provider != originalProvider))
{
throw new InvalidOperationException(“Chain of querying was broken.”);
}
this.collection = (collection as IQueryable<E>) ?? collection.AsQueryable();
this.providersChecked = false;
}
/// <summary>
/// Základní přístup k projekci. Ponechává IQueryable tak, jak bylo vytvořeno.
/// </summary>
/// <returns></returns>
public IQueryable<E> Project()
=> collection;
/// <summary>
/// Projection of current Projector IQueryable to a new collection of re-typed entities.
/// (If unable to re-type, it will copy entities by property name and property type matching.)
/// </summary>
/// <typeparam name=”ME”>Entity Type</typeparam>
/// <returns>Collection ME</returns>
public IQueryable<ME> ProjectTo<ME>()
where ME : new()
{
object result = collection;
if (typeof(ME) != typeof(E))
{
if (CanCast<ME>())
{
result = collection.Cast<ME>();
}
else
{
Expression<Func<E, ME>> selectExpression = GetSelectExpression<ME>();
result = collection.Select(selectExpression);
}
}
return (IQueryable<ME>)result;
}
/// <summary>
/// Projection of current Projector IQueryable to re-typed collection (C) of re-typed entities.
/// (If unable to re-type, it will copy entities by property name and property type matching.)
/// </summary>
/// <typeparam name=”C”>Collection Type</typeparam>
/// <typeparam name=”ME”>Entity Type</typeparam>
/// <returns>Collection C</returns>
public C ProjectTo<C, ME>()
where ME : new()
where C : IEnumerable<ME>
{
object result = collection;
if (typeof(C) == typeof(IEnumerable))
{
if (typeof(ME) == typeof(E))
{
result = collection.AsEnumerable();
}
else
{
if (CanCast<ME>())
{
result = collection.Cast<ME>().AsEnumerable();
}
else
{
Expression<Func<E, ME>> selectExpression = GetSelectExpression<ME>();
result = collection.Select(selectExpression).AsEnumerable();
}
}
}
else if (typeof(ME) != typeof(E))
{
if (CanCast<ME>())
{
result = collection.Cast<ME>();
}
else
{
Expression<Func<E, ME>> selectExpression = GetSelectExpression<ME>();
result = collection.Select(selectExpression);
}
}
return (C)result;
}
/// <summary>
/// Projection of current Projector IQueryable to a new collection of re-typed entities.
/// (If unable to re-type, it will copy entities using AutoMapper.)
/// </summary>
/// <typeparam name=”ME”>Entity Type</typeparam>
/// <returns>Collection ME</returns>
public IQueryable<ME> ProjectTo<ME>(IMapper mapper)
where ME : new()
{
object result = collection;
if (typeof(ME) != typeof(E))
{
if (CanCast<ME>())
{
result = collection.Cast<ME>();
}
else
{
result = collection.Select(e => mapper.Map<ME>(e));
}
}
return (IQueryable<ME>)result;
}
/// <summary>
/// Projection of current Projector IQueryable to re-typed collection (C) of re-typed entities.
/// (If unable to re-type, it will copy entities using AutoMapper.)
/// </summary>
/// <typeparam name=”C”>Collection Type</typeparam>
/// <typeparam name=”ME”>Entity Type</typeparam>
/// <returns>Collection C</returns>
public C ProjectTo<C, ME>(IMapper mapper)
where ME : new()
where C : IEnumerable<ME>
{
object result = collection;
if (typeof(C) == typeof(IEnumerable))
{
if (typeof(ME) == typeof(E))
{
result = collection.AsEnumerable();
}
else
{
if (CanCast<ME>())
{
result = collection.Cast<ME>().AsEnumerable();
}
else
{
result = collection.Select(e => mapper.Map<ME>(e)).AsEnumerable();
}
}
}
else if (typeof(ME) != typeof(E))
{
if (CanCast<ME>())
{
result = collection.Cast<ME>();
}
else
{
result = collection.Select(e => mapper.Map<ME>(e));
}
}
return (C)result;
}
private bool CanCast<ME>()
=> typeof(E).IsAssignableFrom(typeof(ME));
/// <summary>
/// Inner method for Select Linq creation. (Solving property tests and their conversions.)
/// </summary>
/// <typeparam name=”ME”>Entity Type</typeparam>
/// <returns>Lambda Expression Linq Select</returns>
/// <exception cref=”InvalidOperationException”></exception>
private Expression<Func<E, ME>> GetSelectExpression<ME>()
{
Type
sourceType = typeof(E),
targetType = typeof(ME);
PropertyInfo[] sourceProperties = sourceType.GetProperties();
Dictionary<string, PropertyInfo> targetProperties = targetType.GetProperties()
.ToDictionary(key => key.Name, val => val);
ParameterExpression parameter = Expression.Parameter(sourceType, “entity”);
List<MemberBinding> bindings = new List<MemberBinding>();
foreach (PropertyInfo sourceProperty in sourceProperties)
{
if (!targetProperties.ContainsKey(sourceProperty.Name))
{
continue;
}
PropertyInfo? targetProperty = targetProperties[sourceProperty.Name];
Type sourcePropertyType = Nullable.GetUnderlyingType(sourceProperty.PropertyType) ?? sourceProperty.PropertyType;
if (!targetProperty.PropertyType.IsAssignableFrom(sourcePropertyType))
{
throw new InvalidOperationException($”Incompatible property types for property {sourceProperty.Name}”);
}
MemberExpression sourceValue = Expression.Property(parameter, sourceProperty);
Expression convertedSourceValue;
if (sourcePropertyType != sourceProperty.PropertyType) // Is Nullable.
{
convertedSourceValue = Expression.Condition(
Expression.Equal(sourceValue, Expression.Constant(null)), // Test null.
Expression.Default(targetProperty.PropertyType), // Default value.
Expression.Convert(Expression.Property(sourceValue, “Value”), targetProperty.PropertyType));
}
else
{
convertedSourceValue = sourceValue;
}
MemberAssignment binding = Expression.Bind(targetProperty, convertedSourceValue);
bindings.Add(binding);
}
MemberInitExpression initializer = Expression.MemberInit(Expression.New(targetType), bindings);
return Expression.Lambda<Func<E, ME>>(initializer, parameter);
}
}
}
Which has a simple FluentAPI with chaining usage:
public class Small
{
public string IXS_REF { get; set; } = null!;
public DateTime LAST_TIME { get; set; }
}
Small ddd = PersonProjector.Create(new List<IPOREF> { new IPOREF { IXS_REF = “AAA”, LAST_TIME = null } })
.FilterWhatever(joinOne, inList)
.Chain<SecondProjector>()
.ProjectTo<Small>()
.First();
It allows you to define single chain of modular queries and apply it to any collection type. For IQueryable it is protecting input Provider, while for IEnumerable allowing to use all IQueryable methods … Final projection can lead to any ancestor allowing to chain another wave of projections …
Hi,I would like to share simple projector system, that is I believe a great improvement for LINQ:using AutoMapper;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace ANeT.SharedData.Projection
{
/// <summary>
/// Base class for any Projector. This design pattern is able to protect input IQueryable for single SQL generation
/// while for IEnumerable allowing to use single query definition by internally representing it as IQueryable.
/// Fill internal method is used to chaining extension modules to final collection (adjusting current collection with new joins, conditions, …).
/// </summary>
/// <typeparam name=”P”>Factory Type</typeparam>
/// <typeparam name=”E”>Entity Type</typeparam>
public abstract class Projector<P, E>
where P : Projector<P, E>, new()
{
bool providersChecked = false;
IQueryProvider? originalProvider = null;
IQueryable<E> collection = null!;
protected IQueryable<E> Collection => collection;
protected Projector()
{ } // Constructor should be hidden so that internal system is safe.
/// <summary>
/// Factory of this Projector. Accepting any input collection,
/// however for IQueryable it is maintaining a single SQL generation.
/// IEnumerable input is internally represented as IQueryable.
/// </summary>
/// <typeparam name=”C”></typeparam>
/// <param name=”collection”></param>
/// <returns>Instance P</returns>
public static P Create<C>(C collection)
where C : IEnumerable<E>
{
P instance = new P();
if (collection is IQueryable<E> queryable)
{
instance.originalProvider = queryable.Provider;
instance.collection = queryable;
}
else
{
instance.collection = collection.AsQueryable();
}
return instance;
}
/// <summary>
/// Chaining method to follow with next Projector,
/// which one must follow the same entity type.
/// </summary>
/// <typeparam name=”C”>Factory Type</typeparam>
/// <returns>Instance C</returns>
public C Chain<C>()
where C : Projector<C, E>, new()
{
C instance = new C();
instance.originalProvider = this.originalProvider;
instance.collection = this.collection;
return instance;
}
/// <summary>
/// This method should be used at begin of any collection extension.
/// It is enforcing Provider rule on any join collection. (Protecting final collection from cross-context mixup.)
/// </summary>
/// <param name=”collections”>Checked collections</param>
/// <exception cref=”InvalidOperationException”></exception>
protected void CheckProviders(params object[] collections)
{
if (originalProvider == null)
{
return;
}
foreach (object collection in collections)
{
if (collection is IQueryable queryable && queryable.Provider != originalProvider)
{
throw new InvalidOperationException(“Chain of querying was broken.”);
}
}
providersChecked = true;
}
/// <summary>
/// Fill current Projector IQueryable with new altered version.
/// For Projector collection that was IQueryable at the input, it enforces Provider compatibility.
/// (Which is requiring programmers to call CheckProviders beforehand.)
/// </summary>
/// <typeparam name=”C”>Collection Type</typeparam>
/// <param name=”collection”>New collection</param>
/// <exception cref=”InvalidOperationException”></exception>
protected void Fill<C>(C collection)
where C : IEnumerable<E>
{
if (originalProvider != null &&
(!providersChecked || collection is not IQueryable<E> queryable || queryable.Provider != originalProvider))
{
throw new InvalidOperationException(“Chain of querying was broken.”);
}
this.collection = (collection as IQueryable<E>) ?? collection.AsQueryable();
this.providersChecked = false;
}
/// <summary>
/// Základní přístup k projekci. Ponechává IQueryable tak, jak bylo vytvořeno.
/// </summary>
/// <returns></returns>
public IQueryable<E> Project()
=> collection;
/// <summary>
/// Projection of current Projector IQueryable to a new collection of re-typed entities.
/// (If unable to re-type, it will copy entities by property name and property type matching.)
/// </summary>
/// <typeparam name=”ME”>Entity Type</typeparam>
/// <returns>Collection ME</returns>
public IQueryable<ME> ProjectTo<ME>()
where ME : new()
{
object result = collection;
if (typeof(ME) != typeof(E))
{
if (CanCast<ME>())
{
result = collection.Cast<ME>();
}
else
{
Expression<Func<E, ME>> selectExpression = GetSelectExpression<ME>();
result = collection.Select(selectExpression);
}
}
return (IQueryable<ME>)result;
}
/// <summary>
/// Projection of current Projector IQueryable to re-typed collection (C) of re-typed entities.
/// (If unable to re-type, it will copy entities by property name and property type matching.)
/// </summary>
/// <typeparam name=”C”>Collection Type</typeparam>
/// <typeparam name=”ME”>Entity Type</typeparam>
/// <returns>Collection C</returns>
public C ProjectTo<C, ME>()
where ME : new()
where C : IEnumerable<ME>
{
object result = collection;
if (typeof(C) == typeof(IEnumerable))
{
if (typeof(ME) == typeof(E))
{
result = collection.AsEnumerable();
}
else
{
if (CanCast<ME>())
{
result = collection.Cast<ME>().AsEnumerable();
}
else
{
Expression<Func<E, ME>> selectExpression = GetSelectExpression<ME>();
result = collection.Select(selectExpression).AsEnumerable();
}
}
}
else if (typeof(ME) != typeof(E))
{
if (CanCast<ME>())
{
result = collection.Cast<ME>();
}
else
{
Expression<Func<E, ME>> selectExpression = GetSelectExpression<ME>();
result = collection.Select(selectExpression);
}
}
return (C)result;
}
/// <summary>
/// Projection of current Projector IQueryable to a new collection of re-typed entities.
/// (If unable to re-type, it will copy entities using AutoMapper.)
/// </summary>
/// <typeparam name=”ME”>Entity Type</typeparam>
/// <returns>Collection ME</returns>
public IQueryable<ME> ProjectTo<ME>(IMapper mapper)
where ME : new()
{
object result = collection;
if (typeof(ME) != typeof(E))
{
if (CanCast<ME>())
{
result = collection.Cast<ME>();
}
else
{
result = collection.Select(e => mapper.Map<ME>(e));
}
}
return (IQueryable<ME>)result;
}
/// <summary>
/// Projection of current Projector IQueryable to re-typed collection (C) of re-typed entities.
/// (If unable to re-type, it will copy entities using AutoMapper.)
/// </summary>
/// <typeparam name=”C”>Collection Type</typeparam>
/// <typeparam name=”ME”>Entity Type</typeparam>
/// <returns>Collection C</returns>
public C ProjectTo<C, ME>(IMapper mapper)
where ME : new()
where C : IEnumerable<ME>
{
object result = collection;
if (typeof(C) == typeof(IEnumerable))
{
if (typeof(ME) == typeof(E))
{
result = collection.AsEnumerable();
}
else
{
if (CanCast<ME>())
{
result = collection.Cast<ME>().AsEnumerable();
}
else
{
result = collection.Select(e => mapper.Map<ME>(e)).AsEnumerable();
}
}
}
else if (typeof(ME) != typeof(E))
{
if (CanCast<ME>())
{
result = collection.Cast<ME>();
}
else
{
result = collection.Select(e => mapper.Map<ME>(e));
}
}
return (C)result;
}
private bool CanCast<ME>()
=> typeof(E).IsAssignableFrom(typeof(ME));
/// <summary>
/// Inner method for Select Linq creation. (Solving property tests and their conversions.)
/// </summary>
/// <typeparam name=”ME”>Entity Type</typeparam>
/// <returns>Lambda Expression Linq Select</returns>
/// <exception cref=”InvalidOperationException”></exception>
private Expression<Func<E, ME>> GetSelectExpression<ME>()
{
Type
sourceType = typeof(E),
targetType = typeof(ME);
PropertyInfo[] sourceProperties = sourceType.GetProperties();
Dictionary<string, PropertyInfo> targetProperties = targetType.GetProperties()
.ToDictionary(key => key.Name, val => val);
ParameterExpression parameter = Expression.Parameter(sourceType, “entity”);
List<MemberBinding> bindings = new List<MemberBinding>();
foreach (PropertyInfo sourceProperty in sourceProperties)
{
if (!targetProperties.ContainsKey(sourceProperty.Name))
{
continue;
}
PropertyInfo? targetProperty = targetProperties[sourceProperty.Name];
Type sourcePropertyType = Nullable.GetUnderlyingType(sourceProperty.PropertyType) ?? sourceProperty.PropertyType;
if (!targetProperty.PropertyType.IsAssignableFrom(sourcePropertyType))
{
throw new InvalidOperationException($”Incompatible property types for property {sourceProperty.Name}”);
}
MemberExpression sourceValue = Expression.Property(parameter, sourceProperty);
Expression convertedSourceValue;
if (sourcePropertyType != sourceProperty.PropertyType) // Is Nullable.
{
convertedSourceValue = Expression.Condition(
Expression.Equal(sourceValue, Expression.Constant(null)), // Test null.
Expression.Default(targetProperty.PropertyType), // Default value.
Expression.Convert(Expression.Property(sourceValue, “Value”), targetProperty.PropertyType));
}
else
{
convertedSourceValue = sourceValue;
}
MemberAssignment binding = Expression.Bind(targetProperty, convertedSourceValue);
bindings.Add(binding);
}
MemberInitExpression initializer = Expression.MemberInit(Expression.New(targetType), bindings);
return Expression.Lambda<Func<E, ME>>(initializer, parameter);
}
}
} Which has a simple FluentAPI with chaining usage: public class Small
{
public string IXS_REF { get; set; } = null!;
public DateTime LAST_TIME { get; set; }
}
Small ddd = PersonProjector.Create(new List<IPOREF> { new IPOREF { IXS_REF = “AAA”, LAST_TIME = null } })
.FilterWhatever(joinOne, inList)
.Chain<SecondProjector>()
.ProjectTo<Small>()
.First(); It allows you to define single chain of modular queries and apply it to any collection type. For IQueryable it is protecting input Provider, while for IEnumerable allowing to use all IQueryable methods … Final projection can lead to any ancestor allowing to chain another wave of projections … Read More
Microsoft clamps down on Windows 11 users who want local accounts
MS has removed online steps for switching from a Microsoft account to a local one and has killed off a past trick for choosing a local account in Windows 11.
MS has removed online steps for switching from a Microsoft account to a local one and has killed off a past trick for choosing a local account in Windows 11. Read More
Integrating Smart Home Technology with Sheer Curtains
Hi everyone,
I’m exploring ways to integrate smart home technology with my sheer curtains and would love to hear your thoughts and experiences.
Discussion Points:
Smart Curtain Solutions: What are the best smart curtain systems available that work well with sheer curtains?Automation Tips: How have you automated your curtains to sync with other smart home devices like lights or thermostats?Installation Challenges: What challenges have you faced when installing smart curtain systems, and how did you overcome them?
For those looking for more information on curtain options, including smart solutions, I found some useful resources at Dubai Curtains and Blinds . They offer a variety of products and helpful guides.
Looking forward to your insights!
Thanks!
Sheikh Muhammad Bin Zahid
Hi everyone,I’m exploring ways to integrate smart home technology with my sheer curtains and would love to hear your thoughts and experiences.Discussion Points:Smart Curtain Solutions: What are the best smart curtain systems available that work well with sheer curtains?Automation Tips: How have you automated your curtains to sync with other smart home devices like lights or thermostats?Installation Challenges: What challenges have you faced when installing smart curtain systems, and how did you overcome them?For those looking for more information on curtain options, including smart solutions, I found some useful resources at Dubai Curtains and Blinds . They offer a variety of products and helpful guides.Looking forward to your insights!Thanks!Sheikh Muhammad Bin Zahid Read More
5 Free AI Sidekicks To Level Up Your Coding Skills
The article “5 Free AI Sidekicks To Level Up Your Coding Skills” from divdev blog discusses various AI-powered coding assistants that can help programmers boost their productivity. It covers five popular tools, each tool offers unique features like code completion, debugging assistance, and even natural language processing to convert plain English descriptions into functional code. These AI copilots are designed to help coders work more efficiently, navigate complex codebases, and overcome common programming challenges.
If you’re a developer looking to enhance your coding skills and streamline your workflow, this article is a must-read. It provides valuable insights into how AI can complement your coding process and potentially save you hours of work. By exploring these tools, you might discover new ways to tackle coding problems, improve your code quality, and stay up-to-date with the latest AI-assisted coding techniques. Whether you’re a beginner or an experienced programmer, these AI sidekicks could be the key to leveling up your coding game. Check out the full article to learn more about each tool’s specific features and how they can benefit your programming projects:
https://divdev.biz.id/post/ai-coding-copilots
The article “5 Free AI Sidekicks To Level Up Your Coding Skills” from divdev blog discusses various AI-powered coding assistants that can help programmers boost their productivity. It covers five popular tools, each tool offers unique features like code completion, debugging assistance, and even natural language processing to convert plain English descriptions into functional code. These AI copilots are designed to help coders work more efficiently, navigate complex codebases, and overcome common programming challenges. If you’re a developer looking to enhance your coding skills and streamline your workflow, this article is a must-read. It provides valuable insights into how AI can complement your coding process and potentially save you hours of work. By exploring these tools, you might discover new ways to tackle coding problems, improve your code quality, and stay up-to-date with the latest AI-assisted coding techniques. Whether you’re a beginner or an experienced programmer, these AI sidekicks could be the key to leveling up your coding game. Check out the full article to learn more about each tool’s specific features and how they can benefit your programming projects:https://divdev.biz.id/post/ai-coding-copilots Read More
Question about generative search and visibility for businesses
How does genAI search work, and how does a business become one of the answers genAI gives? How do you get into the ‘training data’ if that is required.
For a new business, they simply won’t be in the training set when they launch, so it’s going to be very hard to be found. Of course the current issue with the black art of seo is also difficult (I’m experiencing pain for our business as I create a new website because although our seo is ok, our speed is in the toilet so getting punished). So I see an issue for new business, and a lot of it is going ot be small business, trying to get some roots, trying to generate some leads organically. It’s not even really clear where the marketing budget of the future goes when it comes to digital and generative search.
How does genAI search work, and how does a business become one of the answers genAI gives? How do you get into the ‘training data’ if that is required.
For a new business, they simply won’t be in the training set when they launch, so it’s going to be very hard to be found. Of course the current issue with the black art of seo is also difficult (I’m experiencing pain for our business as I create a new website because although our seo is ok, our speed is in the toilet so getting punished). So I see an issue for new business, and a lot of it is going ot be small business, trying to get some roots, trying to generate some leads organically. It’s not even really clear where the marketing budget of the future goes when it comes to digital and generative search. Read More
How to update date depending on cell text
We have a requirement to forecast when a supplier is next due for an audit.
In column A we have the classification, A Critical, B Moderate, C Non-Critical and D Trivial.
In column B we have the date of the last audit.
In column C I would like to have the spreadsheet automatically forecast the date when it is next due.
A Critical – 1 year
B Moderate – 2 year
C Non-Critical – 3 year
D Trivial – N/A
How do I write a formula to do this?
We have a requirement to forecast when a supplier is next due for an audit.In column A we have the classification, A Critical, B Moderate, C Non-Critical and D Trivial.In column B we have the date of the last audit.In column C I would like to have the spreadsheet automatically forecast the date when it is next due.A Critical – 1 yearB Moderate – 2 yearC Non-Critical – 3 yearD Trivial – N/AHow do I write a formula to do this? Read More
[HTTP]:500 – [CorrelationId]:~ [Version]:16.0.0.25012
I use the PnP Modern Search to display search results on my SharePoint page, but I encountered an error like this:
What is causing this problem and how can I fix it?
Thank you
I use the PnP Modern Search to display search results on my SharePoint page, but I encountered an error like this: What is causing this problem and how can I fix it?Thank you Read More
Setting up Limited Account Creation Role in Azure AD
Hi everyone,
I’m looking to set up a specific role in Azure AD that allows a user to only create AD accounts without additional administrative privileges. I’ve explored the default roles but couldn’t find one suitable for this purpose. Could anyone advise on how to create a custom role or modify permissions to achieve this?
Thank you in advance for your assistance!
Best regards,
Bu
Hi everyone,I’m looking to set up a specific role in Azure AD that allows a user to only create AD accounts without additional administrative privileges. I’ve explored the default roles but couldn’t find one suitable for this purpose. Could anyone advise on how to create a custom role or modify permissions to achieve this?Thank you in advance for your assistance!Best regards, Bu Read More
Below powershell script is not working on all the devices
Hi Guys,
I am trying to push below powershell script on intune through the Scripts option in Devices and it is working for some devices but not on all the devices. Basically we want to change the default font from Aptos to Verdana. Please suggest me here.. Powershell champs confirmed there is no issue in the script. FYI, if i run the below script directly in powershell as administrator it will work straight away and change the font in excel. If i don’t run powershell as administrator and run the script it will throw error saying registry access is not allowed. Please help.
if((Test-Path -LiteralPath “HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions”) -ne $true) { New-Item “HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions” -force -ea SilentlyContinue };
if((Test-Path -LiteralPath “HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptionsbinaryoptions”) -ne $true) { New-Item “HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptionsbinaryoptions” -force -ea SilentlyContinue };
New-ItemProperty -LiteralPath ‘HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions’ -Name ‘extractdatadisableui’ -Value 1 -PropertyType DWord -Force -ea SilentlyContinue;
New-ItemProperty -LiteralPath ‘HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions’ -Name ‘font’ -Value ‘Verdana, 11’ -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -LiteralPath ‘HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions’ -Name ‘disableautorepublish’ -Value 1 -PropertyType DWord -Force -ea SilentlyContinue;
New-ItemProperty -LiteralPath ‘HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions’ -Name ‘disableautorepublishwarning’ -Value 0 -PropertyType DWord -Force -ea SilentlyContinue;
New-ItemProperty -LiteralPath ‘HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptionsbinaryoptions’ -Name ‘fupdateext_78_1’ -Value 0 -PropertyType DWord -Force -ea SilentlyContinue;
Thanks,
Ram
Hi Guys,I am trying to push below powershell script on intune through the Scripts option in Devices and it is working for some devices but not on all the devices. Basically we want to change the default font from Aptos to Verdana. Please suggest me here.. Powershell champs confirmed there is no issue in the script. FYI, if i run the below script directly in powershell as administrator it will work straight away and change the font in excel. If i don’t run powershell as administrator and run the script it will throw error saying registry access is not allowed. Please help.if((Test-Path -LiteralPath “HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions”) -ne $true) { New-Item “HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions” -force -ea SilentlyContinue };if((Test-Path -LiteralPath “HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptionsbinaryoptions”) -ne $true) { New-Item “HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptionsbinaryoptions” -force -ea SilentlyContinue };New-ItemProperty -LiteralPath ‘HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions’ -Name ‘extractdatadisableui’ -Value 1 -PropertyType DWord -Force -ea SilentlyContinue;New-ItemProperty -LiteralPath ‘HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions’ -Name ‘font’ -Value ‘Verdana, 11’ -PropertyType String -Force -ea SilentlyContinue;New-ItemProperty -LiteralPath ‘HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions’ -Name ‘disableautorepublish’ -Value 1 -PropertyType DWord -Force -ea SilentlyContinue;New-ItemProperty -LiteralPath ‘HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptions’ -Name ‘disableautorepublishwarning’ -Value 0 -PropertyType DWord -Force -ea SilentlyContinue;New-ItemProperty -LiteralPath ‘HKCU:SoftwarePoliciesMicrosoftoffice16.0exceloptionsbinaryoptions’ -Name ‘fupdateext_78_1’ -Value 0 -PropertyType DWord -Force -ea SilentlyContinue;Thanks,Ram Read More
Can anyone recommend me best vocal remover software for PC?
Hello, I’m looking for a best vocal remover software for PC Windows 11 recently, hoping to remove vocal from a song. I’ve tried several apps, but the effect is not very ideal, the operation is also relatively complicated, and the sound quality is often affected. I wonder if any friends can recommend a vocal remover software that is easy to operate and can maintain the original sound quality as much as possible? If you have good suggestions or experience, please share with me, thank you very much!
Hello, I’m looking for a best vocal remover software for PC Windows 11 recently, hoping to remove vocal from a song. I’ve tried several apps, but the effect is not very ideal, the operation is also relatively complicated, and the sound quality is often affected. I wonder if any friends can recommend a vocal remover software that is easy to operate and can maintain the original sound quality as much as possible? If you have good suggestions or experience, please share with me, thank you very much! Read More
Congratulations to the Nonprofit 2024 Partner of the Year Award Winner and Finalists
Drumroll, please! We’re thrilled to announce the winner and finalists for the Nonprofit 2024 Microsoft Partner of the Year Awards.
Congratulations to our outstanding partners, their exceptional work is transforming industries and making a lasting impact!
WINNER
We are proud to announce that Valorem Reply has won the Nonprofit 2024 Microsoft Partner of the Year!
FINALISTS
We are excited to share that Exigo Tech, KPMG and Wipfli were recognized as finalists for Nonprofit 2024 Microsoft Partner of the Year!
Read the announcement blog: https://aka.ms/POTYA2024_announcement
Drumroll, please! We’re thrilled to announce the winner and finalists for the Nonprofit 2024 Microsoft Partner of the Year Awards.
Congratulations to our outstanding partners, their exceptional work is transforming industries and making a lasting impact!
WINNER
We are proud to announce that Valorem Reply has won the Nonprofit 2024 Microsoft Partner of the Year!
FINALISTS
We are excited to share that Exigo Tech, KPMG and Wipfli were recognized as finalists for Nonprofit 2024 Microsoft Partner of the Year!
Read the announcement blog: https://aka.ms/POTYA2024_announcement
Read More
Video analytics anonymous users
Hello
Regarding video analytics, we generated a link so that any user can open it, which was shared with hundreds of users. When reviewing the analytics, we observed that the information only reflects the views of those users who belong to the same tenant.
Are all those views made by anonymous users not counted?
HelloRegarding video analytics, we generated a link so that any user can open it, which was shared with hundreds of users. When reviewing the analytics, we observed that the information only reflects the views of those users who belong to the same tenant.Are all those views made by anonymous users not counted? Read More
Security personal access
Hi Please advise. I cannot access security in my MS account. asking for authentication via app or email. My email has been changed on my account but old email is shown (which is now inactive). Where do I go to get help? TIA
Hi Please advise. I cannot access security in my MS account. asking for authentication via app or email. My email has been changed on my account but old email is shown (which is now inactive). Where do I go to get help? TIA Read More
AD CS Server use RPC port 40008
Hello,
i wanna allow the computers to request certificats from our AD CS 2016 Server on the firewall.
Many docs mention that RPC use the dynamic port range 49152-65535, but the test computer tried to join the AD CS server on a lower port 40008/TCP
Hello, i wanna allow the computers to request certificats from our AD CS 2016 Server on the firewall. Many docs mention that RPC use the dynamic port range 49152-65535, but the test computer tried to join the AD CS server on a lower port 40008/TCP Read More
Unable to receive emails
Hello
Please i need your help on this issue.
One of my customers is experiencing an issue where they are unable to receive emails, although they can send emails to external recipients.
They are not receiving any email, but they are able to send email to outsiders.
Hello Please i need your help on this issue. One of my customers is experiencing an issue where they are unable to receive emails, although they can send emails to external recipients.They are not receiving any email, but they are able to send email to outsiders. Read More