gpt4 book ai didi

c# - 如何在 DotNetNuke 中以编程方式创建文件夹并为其分配权限?

转载 作者:太空宇宙 更新时间:2023-11-03 22:16:38 25 4
gpt4 key购买 nike

我已经在根门户目录上以编程方式在 DotNetNuke 中创建了一个文件夹。我只想为它分配一次权限,例如我想让它只对经过身份验证的用户只读。关于如何使用 C# 或 VB.NEt 完成此操作的任何建议?

谢谢。

最佳答案

这相当复杂:

var folderController = new FolderController();
var folderId =
folderController.AddFolder(
new FolderInfo(
portalId,
folderName,
(int)FolderController.StorageLocationTypes.InsecureFileSystem,
isProtected: false,
isCached: false,
lastUpdated: Null.NullDate));
var folder = folderController.GetFolderInfo(portalId, folderId);
Directory.CreateDirectory(folder.PhysicalPath);

var permissionController = new PermissionController();
var writePermission = permissionController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "WRITE").Cast<PermissionInfo>().Single();
var registeredUserRole = new RoleController().GetRoleByName(folder.PortalID, "Registered Users");
folder.FolderPermissions.Add(new FolderPermissionInfo
{
FolderID = folder.FolderID,
PermissionID = writePermission.PermissionID,
RoleID = registeredUserRole.RoleID,
UserID = Null.NullInteger,
PermissionKey = writePermission.PermissionKey,
AllowAccess = false
});

关于c# - 如何在 DotNetNuke 中以编程方式创建文件夹并为其分配权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4928107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com