/// <summary> /// Get the entities from the service /// </summary> /// <returns>The list of entities</returns> protected override IEnumerable <AzureSqlServerActiveDirectoryAdministratorModel> GetEntity() { List <AzureSqlServerActiveDirectoryAdministratorModel> currentActiveDirectoryAdmins = null; try { AzureSqlServerActiveDirectoryAdministratorModel model = ModelAdapter.GetServerActiveDirectoryAdministrator(this.ResourceGroupName, this.ServerName); if (model != null) { currentActiveDirectoryAdmins = new List <AzureSqlServerActiveDirectoryAdministratorModel>(); currentActiveDirectoryAdmins.Add(model); } } catch (CloudException ex) { if (ex.Response.StatusCode != System.Net.HttpStatusCode.NotFound) { // Unexpected exception encountered throw; } } catch (Exception ex) { if ((ex.InnerException is CloudException ex1) && ex1.Response.StatusCode != System.Net.HttpStatusCode.NotFound) { throw ex.InnerException ?? ex; } } return(currentActiveDirectoryAdmins); }
/// <summary> /// Converts the response from the service to a powershell database object /// </summary> /// <param name="resourceGroupName">The resource group the server is in</param> /// <param name="serverName">The name of the Azure Sql ServerActiveDirectoryAdministrator Server</param> /// <param name="admin">The service response</param> /// <returns>The converted model</returns> public static AzureSqlServerActiveDirectoryAdministratorModel CreateServerActiveDirectoryAdministratorModelFromResponse(string resourceGroup, string serverName, Management.Sql.LegacySdk.Models.ServerAdministrator admin) { AzureSqlServerActiveDirectoryAdministratorModel model = new AzureSqlServerActiveDirectoryAdministratorModel(); model.ResourceGroupName = resourceGroup; model.ServerName = serverName; model.DisplayName = admin.Properties.Login; model.ObjectId = admin.Properties.Sid; return(model); }
/// <summary> /// Converts the response from the service to a powershell database object /// </summary> /// <param name="resourceGroupName">The resource group the server is in</param> /// <param name="serverName">The name of the Azure Sql ServerActiveDirectoryAdministrator Server</param> /// <param name="admin">The service response</param> /// <returns>The converted model</returns> public static AzureSqlServerActiveDirectoryAdministratorModel CreateServerActiveDirectoryAdministratorModelFromResponse(string resourceGroup, string serverName, Management.Sql.Models.ServerAzureADAdministrator admin) { if (admin != null) { AzureSqlServerActiveDirectoryAdministratorModel model = new AzureSqlServerActiveDirectoryAdministratorModel(); model.ResourceGroupName = resourceGroup; model.ServerName = serverName; model.DisplayName = admin.Login; model.ObjectId = admin.Sid; model.IsAzureADOnlyAuthentication = admin.AzureADOnlyAuthentication; return(model); } return(null); }
/// <summary> /// Creates or updates an Azure SQL Server Active Directory administrator. /// </summary> /// <param name="resourceGroup">The name of the resource group</param> /// <param name="serverName">The name of the Azure Sql ServerActiveDirectoryAdministrator Server</param> /// <param name="model">The input parameters for the create/update operation</param> /// <returns>The upserted Azure SQL Server Active Directory administrator</returns> internal AzureSqlServerActiveDirectoryAdministratorModel UpsertServerActiveDirectoryAdministrator(string resourceGroup, string serverName, AzureSqlServerActiveDirectoryAdministratorModel model) { var resp = Communicator.CreateOrUpdate(resourceGroup, serverName, GetActiveDirectoryInformation(model.DisplayName, model.ObjectId)); return(CreateServerActiveDirectoryAdministratorModelFromResponse(resourceGroup, serverName, resp)); }
/// <summary> /// Creates or updates an Azure SQL Server Active Directory administrator. /// </summary> /// <param name="resourceGroup">The name of the resource group</param> /// <param name="serverName">The name of the Azure Sql ServerActiveDirectoryAdministrator Server</param> /// <param name="model">The input parameters for the create/update operation</param> /// <returns>The upserted Azure SQL Server Active Directory administrator</returns> internal AzureSqlServerActiveDirectoryAdministratorModel UpsertServerActiveDirectoryAdministrator(string resourceGroup, string serverName, AzureSqlServerActiveDirectoryAdministratorModel model) { var resp = Communicator.CreateOrUpdate(resourceGroup, serverName, Util.GenerateTracingId(), new ServerAdministratorCreateOrUpdateParameters() { Properties = GetActiveDirectoryInformation(model.DisplayName, model.ObjectId) }); return(CreateServerActiveDirectoryAdministratorModelFromResponse(resourceGroup, serverName, resp)); }