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