Aspnetdb Stored Procedure (3) role management

Source: Internet
Author: User
  1. Create a role.Create procedureAspnet_roles_createrole (@ applicationnameNvarchar(256), @ rolenameNvarchar(256) The process first calls aspnet_applications_createapplication to register the applicationProgram;
    Then, add the role data to the role table (aspnet_roles.

    Return Value: 0 is returned for success;
    The role already exists. 1 is returned.
    If an error occurs,-1 is returned.

  2. Deletes a specified role.Create procedureAspnet_roles_deleterole (@ applicationnameNvarchar(256), @ rolenameNvarchar(256), @ deleteonlyifroleisemptyBit)

    Input @ deleteonlyifroleisempty to indicate whether the role is only associated with any user
    (This role does not exist in the aspnet_usersinroles table ).
    Delete a role from the role table (aspnet_roles.

    Return Value: 0 is returned for success;
    If the application is not registered, 1 is returned;
    If the role does not exist, 1 is returned;
    Data of the referenced role exists in the aspnet_usersinroles table, and 2 is returned;

  3. Query (all) Roles and return the role name dataset.
    Create procedureAspnet_roles_getallroles (@ applicationnameNvarchar(256 ))
  4. Check whether the role exists.

    Create procedureAspnet_roles_roleexists (@ applicationnameNvarchar(256), @ rolenameNvarchar(256) returned value: the role exists, and 1 is returned;
    If the role does not exist, 0 is returned.

  5. add data in batches to the aspnet_usersinroles table.

    Create procedure aspnet_usersinroles_adduserstoroles (@ applicationname nvarchar (256), @ usernames nvarchar (4000 ), @ rolenames nvarchar (4000), @ currenttimeutc datetime )

    This process associates a batch of users with a batch of specified roles.
    If the user does not exist, add the user to the user table (aspnet_users) first.

    enter the parameter @ usernames at an interval of ',' .
    enter the parameter @ rolenames with the role names separated by ',' .

    return value: 0 is returned for success.
    2 is returned if the application is not registered.
    If a role in @ rolenames does not exist in the role table, 2 is returned;
    If any user role combination in @ usernames and @ rolenames
    already exists in the aspnet_usersinroles table, 3 is returned.

  6. batch delete data from the aspnet_usersinroles table. Create procedure aspnet_usersinroles_removeusersfromroles (@ applicationname nvarchar (256 ), @ usernames nvarchar (4000), @ rolenames nvarchar (4000) enter the @ usernames parameter and separate the usernames with ',' .
    enter the parameter @ rolenames with the role names separated by ',' .

    returned value: 0 is returned for success.
    If the application is not registered, 2 is returned;
    if a user in @ usernames does not exist in the User table, 1 is returned.
    If a role in @ rolenames does not exist in the role table, 2 is returned;
    If the combination of @ usernames and @ rolenames does not exist in aspnet_usersinroles, 3 is returned.

  7. (Like) queries users with a specified role and whose username matches @ usernametomatch, and returns the username dataset.

    Create procedureAspnet_usersinroles_findusersinrole (@ applicationnameNvarchar(256), @ rolenameNvarchar(256), @ usernametomatchNvarchar(256) Return Value: 0 is returned successfully;
    If the application is not registered, 1 is returned;
    The role does not exist. 1 is returned.

  8. Query the user of a specified role and return the user name dataset.Create procedureAspnet_usersinroles_getusersinroles (@ applicationnameNvarchar(256), @ rolenameNvarchar(256 ))

    Return Value: 0 is returned for success;
    If the application is not registered, 1 is returned;
    The role does not exist. 1 is returned.

  9. Query the role of a specified user and return the role name dataset.Create procedureAspnet_usersinroles_getrolesforuser (@ applicationnameNvarchar(256), @ usernameNvarchar(256 ))

    Return Value: 0 is returned for success;
    If the application is not registered, 1 is returned;
    If the user does not exist, 1 is returned;

  10. Check whether the relevant records in the aspnet_usersinroles table exist.Create procedureAspnet_usersinroles_isuserinrole (@ applicationnameNvarchar(256), @ usernameNvarchar(256), @ rolenameNvarchar(256 ))

    Returned value: the application is not registered, and 1 is returned;
    If the user does not exist, 2 is returned;
    If the role does not exist, 2 is returned;
    If the @ username and @ username combinations exist in the aspnet_usersinroles table, 1 is returned;
    If it does not exist, 0 is returned.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.