Multiple users delete from Azure AD - azure-active-directory

I have "Office 365 Enterprise E3" subscription in Azure.
Suppose, I have a many users and i want to delete multiple users(more than 100).
so, how to do this ?

You could use Delete user operation using Azure AD Graph API . If you want to reduce roundtrips to the server , try batch operations on user entities. Here is a code sample shows how to query Azure Active Directory Graph API using Batch processing .
Another choice is using powershell .You can remove bulk users accounts(use csv file to store user accounts) by :
Import-CSV C:\Users.csv | Remove-MsOlUser –Force
Here is an article shows bulk remove Azure Active Directory user using powershell .

Related

Access multiple database in Azure SQL

I have created 2 azure security groups (Read-SQL and the second is Write-SQL) in order for them to login into multiple Azure SQL servers via SSMS using their Azure AD identity based on their group membership in order to access multiple databases on those services.
First of all I have configured an admin group on the SQL Server in our Azure tenant.
I have connected to the SQL via SSMS using my credentials and so far so good.
After that I opened a query and typed in master database
CREATE USER [SQL-READ] FROM external provider
ALTER ROLE db_datareader ADD MEMBER [SQL-READ];
(Did the same thing for Write-SQL)
only the user is created and no permission given with an error saying the user does not exist or I don't have permission.
I have Azure global administrator permission in Azure and I don't know why I get this error.
In the bottom line I would like that Read-SQL and Write-SQL will be able to login in to the SQL Server and have access to all databases within it as well as giving Read-SQL reading permissions and to Write-SQL writing permission.
I read a few Microsoft articles but I got even more confused since I don't know if I need to create a login or create a user or a contained user.
Please help
Thank you
Here are few screenshots for better understanding
enter image description here
enter image description here
Read the following articles but only partial success.
https://www.mssqltips.com/sqlservertip/6751/azure-ad-authentication-azure-sql-databases/
https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure?view=azuresql&tabs=azure-powershell#create-contained-users-mapped-to-azure-ad-identities
https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-overview?view=azuresql
https://learn.microsoft.com/en-us/sql/relational-databases/security/contained-database-users-making-your-database-portable?view=sql-server-ver16
Whether you should create a login, user or contained user will depend on your access and security requirements. However, in Azure SQL Database, users are created per database. So, you can create the login in the master database and then you need to create the associated user in each database on that SQL Server.
This documentation gives more information on creating logins, users and contained users for Azure SQL Database.

Azure Active Directory Automatically Add/remove groups from Device

I was wondering if it's possible to automate add/remove group memberships from devices?
Basic concept: I have a bunch of devices with a certain group-role. I want to remove this group role from a device if the device display name matches a record in a .csv file. How would I approach this?
extra info: Azure AD joined devices.
• Yes, you can add/remove devices which is a member of multiple groups in Azure AD. But you need to maintain a file, i.e., a csv file as you said for each group that exists in your environment. You can also create a custom role assignment for this purpose and assign it the ‘microsoft.directory/groups/members/update’ permissions so that the user which is assigned this role assignment will have privileges to only update(add/delete/modify) the groups in Azure AD.
• For this purpose, you can use the below script by logging into Azure Powershell through the custom role assigned user id and executing it by locating the correct csv file for the respective groups to remove the device from the respective group. Also, request you to download the updated CSV file for the group from which devices are to be removed from Azure AD.
‘ $cred=Get-credentials
Connect-AzureAD $cred
$devices=Import-Csv -Path ‘<Path of the csv file containing group members
details>’
foreach($device in $devices){
Remove-AzureADGroupMember -ObjectId “ObjectID of the Group” -MemberID
$device.ObjectId
} '
• However, you will have to use ‘Object ID’ parameter of the device rather than ‘Display Name’ as display name as an argument is not supported in ‘Remove members from group’ operation.
Please refer the below link for more details: -
https://learn.microsoft.com/en-us/powershell/module/azuread/remove-azureadgroupmember?view=azureadps-2.0

How can I get a list of Azure AD usernames in Power BI / SQL Server Query based on the users GUIDs?

Have a table in SQL Server with a column "ModifiedBy" with Azure AD users GUIDs.
How can I get back the usernames - in an SQL query?
Actually need this for a Power BI report - so a conversion function in Power BI would also work.
You can use PowerShell script to get the list of Azure AD users with GUID, Username and Display name. This data can be exported to a CSV File.
Please use the below PowerShell script :
Connect-AzureAD
get-azureaduser | Select-Object ObjectId,UserPrincipalName,DisplayName | export-csv csv-file-path
This script will fetch all the users in the Azure AD with GUID, Username and Display name and export it to a CSV file.
Now you can import the data from your CSV file to SQL Server or Azure SQL Database by following any of the methods described in the below document :
Import data from Excel to SQL - SQL Server | Microsoft Docs
You can use JOIN to query the two tables and get the usernames

Grant Read access to Azure Active Directory Group in SQL DW (Synapse)

Can anybody help me with this, I'm stuck and reading didn't get me anywhere :(
My question is related to Azure Active Directory Group and SQL DW. I want to give database read access to an Azure Active Directory Group (ADD group). I took these steps for that:
I made two groups in ADD as Azure AnalytcisDW Admin Users and Azure AnalytcisDW Database Users, each with a bunch of users.
Then, I went to Azure Portal, selected my SQL DW and added Azure AnalytcisDW Admin Users group as Active Directory Admin (image below).
Then, I checked in SSMS and saw Azure AnalytcisDW Admin Users group is under mater=>Security=>Users (see image below)
Now I want to give Azure AnalytcisDW Database Users group the (database) read permission (using SSMS or anything). I couldn't figure out how. I read a bunch of stuff for it and couldn't find my way through, such as:
Grant Access to SQL Server Table to AD user
Adding Users to Azure SQL Databases
I was able to do the same by using the below commands where db_users(same as your Azure AnalytcisDW Database Users) is the active directory group and I have used an id from db_admin (same as your Azure AnalytcisDW Admin Users) to connect to Synapse.
Ref doc : RoleAssign, AADGroupUser

Copy AD users from one Windows server 2012 R2 to another

We are setting up our prod machines in azure cloud. So we need to copy our Active Directory users from existing prod machine which is on premise. When I searched for options, I got articles related to restoring Server state which will have AD back up as well. But I want to restore only AD users. Can you please tell me if there is any way to do it?
First, you need to export the users from existing on-premises domain controller. You can leverage the Powershell Script below to export AD users to CSV.
Powershell Script to export Active Directory users to CSV
Then, you can import the CSV by using the command below from Active Directory Powershell module. For more details, you can refer to the following article.
Import-CSV C:\Users.csv | New-ADUser
Import Bulk Users to Active Directory
Also, there is a tool which can also be used to import the CSV into Active Directory. You can get it from the link below.
Active Directory User Creation tool 1.2

Resources