Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlDatabaseUser: New resource #846

Closed
bozho opened this issue Sep 25, 2017 · 3 comments · Fixed by #1391
Closed

SqlDatabaseUser: New resource #846

bozho opened this issue Sep 25, 2017 · 3 comments · Fixed by #1391
Labels
enhancement The issue is an enhancement request. resource proposal The issue is proposing a new resource in the resource module.

Comments

@bozho
Copy link
Contributor

bozho commented Sep 25, 2017

xSQLServerDatabaseRole currently handles DB user creation and role assignment (for already existing roles)

The name is a bit confusing, since the name implies the resource actually handles DB roles creation/removal.

I suggest we rename xSQLServerDatabaseRole to XSQLServerDatabaseUser.

The new resource xSQLServerDatabaseRole would then handle DB roles.

@johlju
Copy link
Member

johlju commented Sep 26, 2017

I agree to rename this resource, and change so that this resource only handles creation and dropping of database user.

This must be merged at the same time (or close to the same time) as the issue #847 is merged.

@johlju johlju added breaking change When used on an issue, the issue has been determined to be a breaking change. enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. resource proposal The issue is proposing a new resource in the resource module. labels Sep 26, 2017
@johlju johlju changed the title [Resource proposal] xSQLServerDatabaseUser (or rename xSQLServerDatabaseRole) xSQLServerDatabaseUser: New resource Sep 26, 2017
@johlju
Copy link
Member

johlju commented Sep 26, 2017

Practically, to be able to create a PR for this issue and issue #847, I think it would be best to not rename this resource but instead, if it helps, copy the code from the xSQLServerDatabaseRole to the new resource xSQLServerDatabaseUser and change the code there. This will make it possible to change to xSQLServerDatabaseRole without merge conflicts.

@johlju johlju changed the title xSQLServerDatabaseUser: New resource SqlDatabaseUser: New resource Dec 24, 2017
@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. breaking change When used on an issue, the issue has been determined to be a breaking change. labels Jul 13, 2019
@johlju
Copy link
Member

johlju commented Jul 13, 2019

This is the proposed schema. Please comment if you see anything that needs to be changed.

[ClassVersion("1.0.0.0"), FriendlyName("SqlDatabaseUser")]
class MSFT_SqlDatabaseUser : OMI_BaseResource
{
    [Key, Description("Specifies the name of the database user to be added or removed.")] String Name;
    [Key, Description("Specifies the host name of the SQL Server on which the instance exist.")] String ServerName;
    [Key, Description("Specifies the SQL instance in which the database exist.")] String InstanceName;
    [Key, Description("Specifies the name of the database in which to configure the user.")] String DatabaseName;
    [Write, Description("Specifies the name of the SQL login to associate with the database user. This must be specified if parameter UserType is set to 'Login'.")] String LoginName;
    [Write, Description("Specifies the name of the asymmetric key to associate with the database user. This must be specified if parameter UserType is set to 'AsymmetricKey'.")] String AsymmetricKeyName;
    [Write, Description("Specifies the name of the certificate to associate with the database user. This must be specified if parameter UserType is set to 'Certificate'.")] String CertificateName;
    [Write, Description("Specifies the user type of the database user. Valid values are 'Login', 'NoLogin', 'Certificate', or 'AsymmetricKey'. Defaults to 'Login'."), ValueMap{"Login", "NoLogin", "Certificate", "AsymmetricKey"}, Values{"Login", "NoLogin", "Certificate", "AsymmetricKey"}] String UserType;
    [Write, Description("Specifies if the user should be present or absent. If 'Present' then the user will be added to the database and, if needed, the login mapping will be updated. If 'Absent' then the user will be removed from the database. Defaults to 'Present'."), ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}] String Ensure;
    [Read, Description("Returns the authentication type of the SQL login connected to the database user. This will return either 'Windows', 'Instance' or 'None'. The value 'Windows' means the SQL login is using Windows Authentication, 'Instance' means that the SQL login is using SQL authentication, and 'None' means that the database user have no SQL login connected to it.")] String AuthenticationType;
    [Read, Description("Returns the login type of the SQL login connected to the database user. If no SQL login is connected to the database user this returns $null.")] String LoginType;
};

johlju pushed a commit that referenced this issue Jul 17, 2019
- Changes to SqlServerDsc
  - New DSC resource SqlDatabaseUser (issue #846).
    - Adds ability to create database users with more fine-grained control,
      e.g. re-mapping of orphaned logins or a different login. Supports
      creating a user with or without login name, and database users mapped
      to a certificate or asymmetric key.
  - Minor style fixes in unit tests.
- Changes to SqlDatabase
  - Get-TargetResource now correctly return `$null` for the collation property
    when the database does not exist (issue #1395).
  - No longer enforces the collation property if the Collation parameter
    is not part of the configuration (issue #1396).
  - Updated resource description in README.md
  - Fix examples to use `PsDscRunAsCredential` (issue #760).
  - Added integration tests (issue #739).
  - Updated unit tests to the latest template (issue #1068).
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request. resource proposal The issue is proposing a new resource in the resource module.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants