Restore the default Moss permission level

Source: Internet
Author: User
The moss website set has five default permission levels: full control, design, participation in discussion, read, and restricted access. However, in actual use cases, it may be insufficient for users or confusing users due to their names. In many cases, you will re-establish the permission level based on the specific permissions to meet the business needs, and delete the original. However, in this way, many feature dependent on the original default permission level in Moss cannot be used, for example, navigation.

In the OM of moss, no methods are provided to restore the default permission level when the system is created, in addition to the full control and restricted access, the deleted files cannot be restored.

However, through the SQL server profile tracking, we found that in createsite. during the process of creating a website set by aspx, Moss will call a stored procedure proc_createsite. In this stored procedure, Moss will call a stored procedure called proc_createdefaultroles, the input parameters of this stored procedure are the default five permission levels, including the name, description, and permission (permmask). Continue to follow up the stored procedure that is passed to the default permission, you will find that the stored procedure for creating the default permission level calls proc_secaddroledef for each permission level to add the default permission level to the database. In addition, the roleid of the permission level is composed of numbers from 1073741824 + [5-2. This means that, after the default permission level is deleted, we can re-Add the default permission level to the website by calling the proc_secaddroledef stored procedure and generating the roleid. You can reset the default website permission level by assigning the website ID (siteid) and website ID (webid) to proc_restoredefaultroles.

CodeAs follows:

Create procedure proc_restoredefaultroles (@ siteid uniqueidentifier, @ webid uniqueidentifier)
As
Set nocount on
Declare @ roleid int
Set @ roleid = 1073741824 + 4
If not exists (select roleid from roles where roleid = @ roleid)
Begin
Exec proc_secaddroledef @ siteid, @ webid, n'design', n' can be viewed, added, updated, deleted, approved, and customized. ', 0, 0, 4, 1856438738519, @ roleid
End
Set @ roleid = 1073741824 + 3
If not exists (select roleid from roles where roleid = @ roleid)
Begin
Exec proc_secaddroledef @ siteid, @ webid, n'participate in the discussion ', n' can be viewed, added, updated, and deleted. ', 0, 0, 3, 1856442500591, @ roleid
End
Set @ roleid = 1073741824 + 2
If not exists (select roleid from roles where roleid = @ roleid)
Begin
Exec proc_secaddroledef @ siteid, @ webid, n'read', n' can only be viewed. ', @ Roleid
End
Return 0

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.