/// <summary> /// Get the entities from the service /// </summary> /// <returns>The list of entities</returns> protected override IEnumerable <AzureSqlServerActiveDirectoryOnlyAuthenticationModel> GetEntity() { List <AzureSqlServerActiveDirectoryOnlyAuthenticationModel> currentActiveDirectoryOnlyAuthentications = null; try { AzureSqlServerActiveDirectoryOnlyAuthenticationModel model = ModelAdapter.GetServerActiveDirectoryOnlyAuthentication(this.ResourceGroupName, this.ServerName); if (model != null) { currentActiveDirectoryOnlyAuthentications = new List <AzureSqlServerActiveDirectoryOnlyAuthenticationModel>(); currentActiveDirectoryOnlyAuthentications.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(currentActiveDirectoryOnlyAuthentications); }
/// <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 AzureSqlServerActiveDirectoryOnlyAuthenticationModel CreateServerActiveDirectoryOnlyAuthenticationModelFromResponse(string resourceGroup, string serverName, Management.Sql.Models.ServerAzureADOnlyAuthentication serverAzureADOnlyAuthentication) { if (serverAzureADOnlyAuthentication != null) { AzureSqlServerActiveDirectoryOnlyAuthenticationModel model = new AzureSqlServerActiveDirectoryOnlyAuthenticationModel(); model.ResourceGroupName = resourceGroup; model.ServerName = serverName; model.AzureADOnlyAuthentication = serverAzureADOnlyAuthentication.AzureADOnlyAuthentication; return(model); } return(null); }
/// <summary> /// Enable\Disable Azure Active Directory only authentication on a Azure SQL Server /// </summary> /// <param name="resourceGroup">The name of the resource group</param> /// <param name="serverName">The name of the Azure Sql ServerActiveDirectoryAdministrator Server</param> /// <returns>The upserted Azure SQL Server Active Directory administrator</returns> internal AzureSqlServerActiveDirectoryOnlyAuthenticationModel UpsertAzureADOnlyAuthenticaion(string resourceGroup, string serverName, AzureSqlServerActiveDirectoryOnlyAuthenticationModel model) { var resp = Communicator.CreateOrUpdate(resourceGroup, serverName, new ServerAzureADOnlyAuthentication(model.AzureADOnlyAuthentication)); return(CreateServerActiveDirectoryOnlyAuthenticationModelFromResponse(resourceGroup, serverName, resp)); }