SSAS : How to automate cube processing and user role attribution? - c#

I've been having to give a role to new users, problem I have to add them to 2 different cubes in 6 different environments, which is 12 times adding the user and processing the rights table, which amounts to around an hour on my company's rather weak laptop, for EVERY new user.
Is there any way to juste write some code with a list of users you wanna add to a list of cubes, and you'd just tell it to process the table after each addition ? It'd be a real life saver right now.

In SSIS, you can use the Analysis Services Execute DDL Task. This can take a TMSL script as input, which would look like below.
1) sequence - this command allows you to perform multiple operations
2) createOrReplace - this will refresh the role with the new list of members. Note that every existing member needs to be included in the role or they will be wiped out
3) refresh - processes the table
In ssis, you might create a connection to each environment and loop through a set of script files, so that you would not need to modify the package to add new members.
However, I would also suggest switching to an AD group instead of adding explicit users to the role. Then you would only need to refresh table.
{
"sequence": {
"operations": [{
"createOrReplace": {
"object": {
"database": "<Your Database>",
"role": "<Your Role Name>"
},
"role": {
"name": "Reader",
"modelPermission": "read",
"members": [{
"memberName": "<Your Domain>\\<User 1>",
"memberName": "<Your Domain>\\<User 2>",
<All the users in the role...>
}
]
}
}
}, {
"refresh": {
"type": "full",
"objects": [{
"database": "<Your Database>",
"table": "<Your Table>"
}
]
}
}
]
}
}

Related

How to use resource and role based authorization on AspNet Core 3.1 with EF Core?

I'm working on a marketplace backend application with role based authorization, and I'm handling access to actions using those roles. The admins manage all products and their filtering categories while the sellers choose which one to sell, with its filter options and its price. By the way, I'm quite new to asp.net core and ef core, so forgive me if this is a simple request.
If a seller sends a put request with data like this, it can update the filter option name, but that is a action that should be available only to admins on another path/action.
Is there a simple good solution other than create specific models for each action? Something like block the update access to that resource when it's part of another one?
{
"productId": "1",
"options": [
{
"filterCategoryId": "2",
"filterOptionId": "4",
"filterOptionName": "Blue"
},
{
"filterCategoryId": "1",
"filterOptionId": "1",
"filterOptionName": "XL"
}
],
"price": "123.00",
"amount": "5"
}
You can use User.IsInRole("roleName") in the Action to control whether or not the filter options may be changed. For Example:
public async Task<ActionResult>(ProductDetails p)
{
if(User.IsInRole("Administrator"))
{
//Update Filter Names
}
//do whatever else you need to...
}

Individual user settings in ASP.Net Core 3.1

I need to have bunch of settings for each user. Theese settings are same for all the users but every user can change their values. I'm looking for a good approach to create such an infrastructure. My best guess for now is table with all the settings in DB and a table with SettingId UserId and value. Not sure this is the best way tho.
In .net core , you can also use appsettings.json to store such configuration like as below:
{
"Users": {
"Arun": {
"Id": "ArunId",
"Name": "ArunName"
},
"Santa": {
"Id": "SantaId",
"Name": "SantaName"
}
}
}
you can directly convert these to strong type object with help of IConfiguration interface like below :
_configuration.GetSection("Users")

how to run exe file in azure data factroy with input parameters?

i have a console application. i built this application and uploaded it to the Azure blob storage. Then i run this application Azure data factory pipeline. All are fine but the problem is if i want to add new parameters(get input) to console application how can i do that? Is there any specific way to do it?
{
"name": "samplebatch",
"type": "Custom",
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false
},
"typeProperties": {
"command": "SampleApp.exe",
"folderPath": "customactv2/SampleApp",
"resourceLinkedService": {
"referenceName": "StorageLinkedService",
"type": "LinkedServiceReference"
}
"linkedServiceName": {
"referenceName": "dataloadbatchservice",
"type": "LinkedServiceReference"
}
}
This is what i have done so far in the data factory pipeline code.
Please refer to the extendedProperties property in typeProperties, you could use it.
User-defined properties that can be passed to the custom application
in JSON format so your custom code can reference additional properties
Doc: https://learn.microsoft.com/en-us/azure/data-factory/transform-data-using-dotnet-custom-activity#custom-activity
Sample:https://github.com/Azure/Azure-DataFactory/blob/master/Samples/ADFv2CustomActivitySample/MyCustomActivityPipeline.json

Add claims to user through azure ad b2c using graph api

I have a web application and am planning to move all the authentication to Azure AD b2c.
I need to create user through Graph API and now i can create user through Graph API, i also need to add claims
When adding user or updating user, after further googling i found out, you need to add extension property, I tried adding extensions, but it seems to be not working for me. Any help will greatly appreciated.
I am using the sample provided by MSFT https://github.com/AzureADQuickStarts/B2C-GraphAPI-DotNet . I can now create an extension with the below JSON
{
"accountEnabled": true,
"signInNames": [
{
"type": "emailAddress",
"value": "kart.kala1#test.com"
}
],
"creationType": "LocalAccount",
"displayName": "Joe Consumer",
"mailNickname": "joec",
"passwordProfile": {
"password": "P#$$word!",
"forceChangePasswordNextLogin": false
},
"passwordPolicies": "DisablePasswordExpiration",
"city": "San Diego",
"country": null,
"facsimileTelephoneNumber": null,
"givenName": "Joe",
"mail": null,
"mobile": null,
"otherMails": [],
"postalCode": "92130",
"preferredLanguage": null,
"state": "California",
"streetAddress": null,
"surname": "Consumer",
"telephoneNumber": null,
"extension_a550f811ccfe41f19e895f7931f7a28a_admin": "admin1"
}
Above extension_a550f811ccfe41f19e895f7931f7a28a_admin": "admin1" property worked for me to add extension, but i created a user thru sign-signin profile in azure portal and then added the details which is got from "GET-USER" of another user and re-used the name. What is the alpha numeric value? is it created run time or can it be resolved using any value from the user data ?. I will have two accounts stage and production and i cannot be resolving the value or changing it runtime.
Don't have the rep to comment so need to put it in answer form.
I am not entirely sure what the question is, but I have successfully used the Graph API to set/get the extension data (for example using the JSON attribute extension_a550f811ccfe41f19e895f7931f7a28a_admin).
I am not sure how you are getting the user info but it seems as though it might be by name, which may not be unique.
For getting/setting B2C user info you need to use the objectId of the user as it is guaranteed unique. This means you need to store that objectId in your database/storage for that user.

acess tfs to get capacity information

I am trying to get project information from tfs server programitaically.I want to know how to acess the capacity information.Ive serached for it online and it says that that capacity info is stored in [dbo].[tbl_TeamConfigurationCapacity].
But am not understanding how to query for the table using wiql.Anyone have any idea about it ?
This table is only available in the Project Collection database and querying that table is not supported through SQL nor WIQL. While technically possible through SQL, any direct access of the Project Collection database is unsupported and the underlying structure may change between major versions, updates and even hotfixes.
Instead of directly accessing the capacity in the database, the supported method is to use the REST api to query the capacity.
Example:
GET https://{instance}/DefaultCollection/{project}/{team}/_apis/work/TeamSettings/Iterations/{iterationid}/Capacities?api-version={version}
GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/Fabrikam-Fiber/_apis/work/teamsettings/iterations/2ec76bfe-ba74-4060-970d-4567a3e997ee/capacities?api-version=2.0-preview.1
{
"values": [
{
"teamMember": {
"id": "8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d",
"displayName": "Chuck Reinhart",
"uniqueName": "fabrikamfiber3#hotmail.com",
"url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d",
"imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d"
},
"activities": [
{
"capacityPerDay": 0,
"name": null
}
],
"daysOff": [],
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/6d823a47-2d51-4f31-acff-74927f88ee1e/748b18b6-4b3c-425a-bcae-ff9b3e703012/_apis/work/teamsettings/iterations/2ec76bfe-ba74-4060-970d-4567a3e997ee/capacities/8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d"
}
]
}

Categories

Resources