Posts

Showing posts from September, 2024

Microsoft Modern Authentication - SSO

 In some company, getting application level permissions might be hard to do due to security reason.  Within those environment, setting up a job that runs periodically could be difficult.  One of the way to do it is to make sure your job running account has enough permissions and you have a SPN with enough delegated permissions. The below code show how to use the logged in account to get access token for SharePoint scope. public async Task<string> GetSSOUserAccessToken(Uri spSiteUrl) { var _clientId = ""; var _tenantId = ""; var _scheme = siteUrl.Scheme; var _hostUrl = siteUrl.host; var _scope = "AllSites.FullControl"; string[] _scopes = new string[] {string.Format("{0}://{1}/{2}", _schem, _hostUrl, _scope); var authority = string.Format(CultureInfo.InvariantCulture, "{0}/{1}/", "https://login.microsoftonline.com", _tenantId); try {     IPublicClientApplication app = PublicClientApplicationBuilder.Create(_clientId).WithAu...

Azure AI Search filter or search with case insensitive

In case that you have a search index field that was created already and couldn't perform the text normalization to allow default search/filter with case insensitive.  You can have another option if your field is set to searchable. You can use search.ismatch function provided by Azure Cognitive Search to perform a match operation on the specific field. Sample syntax for putting in the SearchOptions will be something like SearchOptions options = new SearchOptions {      Size = 50,      Filter = $"search.ismatch('{url}', 'url', 'simple', 'all')" }; The parameters for ismatch: the actual URL to match the name of the index field 'simple' is specifying t he analyzer to use. The simple analyzer is a basic text analyzer that breaks text into terms based on whitespace and punctuation. 'all' specifies the search mode. The all mode means all of the terms in teh query must match Reference: https://learn.microsoft.com/en-us/azure/searc...