本文整理汇总了C#中DotNetNuke.Security.Roles.RoleController类的典型用法代码示例。如果您正苦于以下问题:C# RoleController类的具体用法?C# RoleController怎么用?C# RoleController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RoleController类属于DotNetNuke.Security.Roles命名空间,在下文中一共展示了RoleController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGroups
public override ArrayList GetGroups()
{
//Dim adsiConfig As Authentication.ADSI.Configuration = Authentication.ADSI.Configuration.GetConfig(_portalSettings.PortalId)
// Normally number of roles in DNN less than groups in Authentication,
// so start from DNN roles to get better performance
try
{
// Obtain search object
//Dim rootDomain As DirectoryEntry = GetRootDomain()
//Dim objSearch As New ADSI.Search(rootDomain)
ArrayList colGroup = new ArrayList();
RoleController objRoleController = new RoleController();
ArrayList lstRoles = objRoleController.GetPortalRoles( _portalSettings.PortalId );
RoleInfo objRole;
foreach( RoleInfo tempLoopVar_objRole in lstRoles )
{
objRole = tempLoopVar_objRole;
// Auto assignment roles have been added by DNN, so don't need to get them
if( ! objRole.AutoAssignment )
{
// It's possible in multiple domains network that search result return more than one group with the same name (i.e Administrators)
// We better check them all
DirectoryEntry entry;
foreach( DirectoryEntry tempLoopVar_entry in Utilities.GetGroupEntriesByName( objRole.RoleName ) )
{
entry = tempLoopVar_entry;
GroupInfo group = new GroupInfo();
group.PortalID = objRole.PortalID;
group.RoleID = objRole.RoleID;
group.GUID = entry.NativeGuid;
group.Location = Utilities.GetEntryLocation( entry );
group.RoleName = objRole.RoleName;
group.Description = objRole.Description;
group.ServiceFee = objRole.ServiceFee;
group.BillingFrequency = objRole.BillingFrequency;
group.TrialPeriod = objRole.TrialPeriod;
group.TrialFrequency = objRole.TrialFrequency;
group.BillingPeriod = objRole.BillingPeriod;
group.TrialFee = objRole.TrialFee;
group.IsPublic = objRole.IsPublic;
group.AutoAssignment = objRole.AutoAssignment;
// Populate member with distingushed name
PopulateMembership( group, entry );
colGroup.Add( group );
}
}
}
return colGroup;
}
catch( COMException exc )
{
Exceptions.LogException( exc );
return null;
}
}
示例2: DeleteUserRoleInternal
private static bool DeleteUserRoleInternal(int portalId, int userId, int roleId)
{
var roleController = new RoleController();
var user = UserController.GetUserById(portalId, userId);
var userRole = roleController.GetUserRole(portalId, userId, roleId);
var portalController = new PortalController();
bool delete = true;
var portal = portalController.GetPortal(portalId);
if (portal != null && userRole != null)
{
if (CanRemoveUserFromRole(portal, userId, roleId))
{
provider.RemoveUserFromRole(portalId, user, userRole);
var objEventLog = new EventLogController();
objEventLog.AddLog(userRole, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.ROLE_UPDATED);
//Remove the UserInfo from the Cache, as it has been modified
DataCache.ClearUserCache(portalId, user.Username);
TestableRoleController.Instance.ClearRoleCache(portalId);
}
else
{
delete = false;
}
}
return delete;
}
示例3: BindData
/// <summary>
/// BindData gets the roles from the Database and binds them to the DataGrid
/// </summary>
/// <history>
/// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support
/// and localisation
/// [cnurse] 01/05/2006 Updated to reflect Use of Role Groups
/// </history>
private void BindData()
{
// Get the portal's roles from the database
RoleController objRoles = new RoleController();
ArrayList arrRoles;
if( RoleGroupId < - 1 )
{
arrRoles = objRoles.GetPortalRoles( PortalId );
}
else
{
arrRoles = objRoles.GetRolesByGroup( PortalId, RoleGroupId );
}
grdRoles.DataSource = arrRoles;
if( RoleGroupId < 0 )
{
lnkEditGroup.Visible = false;
cmdDelete.Visible = false;
}
else
{
lnkEditGroup.Visible = true;
lnkEditGroup.NavigateUrl = EditUrl( "RoleGroupId", RoleGroupId.ToString(), "EditGroup" );
cmdDelete.Visible = !( arrRoles.Count > 0 );
ClientAPI.AddButtonConfirm( cmdDelete, Localization.GetString( "DeleteItem" ) );
}
Localization.LocalizeDataGrid( ref grdRoles, this.LocalResourceFile );
grdRoles.DataBind();
}
示例4: ShowSettings
protected void ShowSettings()
{
//get the tracking ID
if (ModuleSettings.ContainsKey("GoogleTrackingId"))
txtAnalyticsTrackingId.Text = (string)ModuleSettings["GoogleTrackingId"];
if (ModuleSettings.ContainsKey("LocalHostAddress"))
{
txtLocalHostName.Text = (string)ModuleSettings["LocalHostAddress"];
}
//populate the drop down box
RoleController rc = new DotNetNuke.Security.Roles.RoleController();
ArrayList roles = rc.GetPortalRoles(this.PortalId);
//put in a dummy role to allow no restriction on role
RoleInfo dummyRole = new RoleInfo();
dummyRole.RoleID = -1;
dummyRole.RoleName = "[Do Not Hide Tracking]";
roles.Insert(0, dummyRole);
ddlSecurityGroups.DataSource = roles;
ddlSecurityGroups.DataValueField = "RoleID";
ddlSecurityGroups.DataTextField = "RoleName";
ddlSecurityGroups.DataBind();
//get the security group
if (ModuleSettings.ContainsKey("HideTrackingFromRole"))
{
foreach(ListItem item in ddlSecurityGroups.Items)
{
string value = (string)ModuleSettings["HideTrackingFromRole"];
if (item.Text == value)
ddlSecurityGroups.SelectedValue = item.Value;
}
}
}
示例5: Save_Click
private void Save_Click(object sender, EventArgs e)
{
if (GroupId > 0)
{
RoleController roleController = new RoleController();
Security.PortalSecurity ps = new Security.PortalSecurity();
txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting);
txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup);
var roleInfo = roleController.GetRole(GroupId, PortalId);
if (roleInfo != null)
{
roleInfo.Description = txtDescription.Text;
roleInfo.IsPublic = rdAccessTypePublic.Checked;
if (roleInfo.Settings.ContainsKey("URL"))
{
roleInfo.Settings["URL"] = Globals.NavigateURL(TabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() });
} else
{
roleInfo.Settings.Add("URL", Globals.NavigateURL(TabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }));
}
if (roleInfo.Settings.ContainsKey("ReviewMembers"))
{
roleInfo.Settings["ReviewMembers"] = chkMemberApproved.Checked.ToString();
} else
{
roleInfo.Settings.Add("ReviewMembers", chkMemberApproved.Checked.ToString());
}
TestableRoleController.Instance.UpdateRoleSettings(roleInfo, true);
roleController.UpdateRole(roleInfo);
if (inpFile.PostedFile.ContentLength > 0)
{
IFileManager _fileManager = FileManager.Instance;
IFolderManager _folderManager = FolderManager.Instance;
var rootFolderPath = PathUtils.Instance.FormatFolderPath(PortalSettings.HomeDirectory);
IFolderInfo groupFolder = _folderManager.GetFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
if (groupFolder == null)
{
groupFolder = _folderManager.AddFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
}
if (groupFolder != null)
{
var fileName = Path.GetFileName(inpFile.PostedFile.FileName);
var fileInfo = _fileManager.AddFile(groupFolder, fileName, inpFile.PostedFile.InputStream, true);
roleInfo.IconFile = "FileID=" + fileInfo.FileId;
roleController.UpdateRole(roleInfo);
}
}
}
Response.Redirect(Globals.NavigateURL(TabId, "", new String[] { "groupid=" + GroupId.ToString() }));
}
}
示例6: GetStaffNames
public void GetStaffNames(int portalid, string term)
{
term = term.ToLower();
var result = new DotNetNuke.Security.Roles.RoleController().GetUsersByRole(portalid, "Staff")
.Where(w => w.DisplayName.ToLower().Contains(term) && w.IsDeleted==false)
.Select(s => new { label = s.DisplayName, value = s.UserID })
.OrderBy(o => o.label);
string json = JsonConvert.SerializeObject(result);
HttpContext.Current.Response.ContentType = "application/json";
HttpContext.Current.Response.Write(json);
}
示例7: GivenThereIsAPageCalled
public void GivenThereIsAPageCalled(string pageName, Table permissions)
{
var reset = false;
var tabController = new TabController();
var tab = tabController.GetTabByName(pageName, PortalId);
if (tab == null)
{
tab = new TabInfo
{
TabName = pageName,
PortalID = 0
};
tab.TabID = tabController.AddTab(tab);
foreach (var row in permissions.Rows)
{
var roleId = -1;
var roleController = new RoleController();
if (row[0] == "All Users")
{
roleId = -1;
}
else
{
var role = roleController.GetRoleByName(PortalId, row[0]);
if (role == null)
{
if (roleController.GetRoleByName(Null.NullInteger, row[0]) == null)
{
role = new RoleInfo { RoleName = row[0], RoleGroupID = Null.NullInteger };
roleId = roleController.AddRole(role);
}
}
}
var permissionController = new PermissionController();
var permission = permissionController.GetPermissionByCodeAndKey("SYSTEM_TAB", row[1]);
var tabPermission = new TabPermissionInfo
{
PermissionID = 3,
TabID = tab.TabID,
AllowAccess = true,
RoleID = roleId
};
tab.TabPermissions.Add(tabPermission);
}
tabController.UpdateTab(tab);
reset = true;
}
Page = tab;
if (reset)
{
Config.Touch();
}
}
示例8: DataBind
/// -----------------------------------------------------------------------------
/// <summary>
/// DataBind binds the data to the controls
/// </summary>
/// <history>
/// [cnurse] 03/13/2006 Created
/// </history>
/// -----------------------------------------------------------------------------
public override void DataBind()
{
if (Request.IsAuthenticated)
{
RoleController roleController = new RoleController();
grdServices.DataSource = roleController.GetUserRoles(UserInfo, false);
grdServices.DataBind();
//if no service available then hide options
ServicesRow.Visible = (grdServices.Items.Count > 0);
}
}
示例9: AddClientEditorRole
public void AddClientEditorRole()
{
if (_userInfo != null)
{
if (!_userInfo.IsInRole(StoreSettings.ClientEditorRole))
{
var rc = new DotNetNuke.Security.Roles.RoleController();
var ri = rc.GetRoleByName(PortalId, StoreSettings.ClientEditorRole);
if (ri != null) rc.AddUserRole(PortalId, _userInfo.UserID, ri.RoleID, Null.NullDate, Null.NullDate);
if (StoreSettings.Current.Get("sendclientroleemail") == "True") NBrightBuyUtils.SendEmail(_userInfo.Email, "addclientrole.html", _clientInfo, "", "", _userInfo.Profile.PreferredLocale);
}
}
}
示例10: OnLoad
/// -----------------------------------------------------------------------------
/// <summary>
/// Page_Load runs when the control is loaded
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support
/// and localisation
/// </history>
/// -----------------------------------------------------------------------------
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
cmdCancel.Click += cmdCancel_Click;
cmdDelete.Click += cmdDelete_Click;
cmdUpdate.Click += cmdUpdate_Click;
try
{
if ((Request.QueryString["RoleGroupID"] != null))
{
RoleGroupID = Int32.Parse(Request.QueryString["RoleGroupID"]);
}
if (Page.IsPostBack == false)
{
ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));
var objRoles = new RoleController();
if (RoleGroupID != -1)
{
RoleGroupInfo objRoleGroupInfo = RoleController.GetRoleGroup(PortalId, RoleGroupID);
if (objRoleGroupInfo != null)
{
txtRoleGroupName.Text = objRoleGroupInfo.RoleGroupName;
txtDescription.Text = objRoleGroupInfo.Description;
//Check if Group has any roles assigned
int roleCount = objRoles.GetRolesByGroup(PortalId, RoleGroupID).Count;
if (roleCount > 0)
{
cmdDelete.Visible = false;
}
}
else //security violation attempt to access item not related to this Module
{
Response.Redirect(Globals.NavigateURL("Security Roles"));
}
}
else
{
cmdDelete.Visible = false;
}
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
DotNetNuke.Framework.jQuery.RegisterDnnJQueryPlugins(this.Page);
imgGroup.Src = Page.ResolveUrl("~/DesktopModules/SocialGroups/Images/") + "sample-group-profile.jpg";
if (!Page.IsPostBack && GroupId > 0)
{
RoleController roleController = new RoleController();
var roleInfo = roleController.GetRole(GroupId, PortalId);
if (roleInfo != null)
{
if (!UserInfo.IsInRole(PortalSettings.AdministratorRoleName))
{
if (roleInfo.CreatedByUserID != UserInfo.UserID)
{
Response.Redirect(ModuleContext.NavigateUrl(TabId, "", false, new String[] { "groupid=" + GroupId.ToString() }));
}
}
txtGroupName.Visible = !roleInfo.IsSystemRole;
reqGroupName.Enabled = !roleInfo.IsSystemRole;
if(!roleInfo.IsSystemRole)
txtGroupName.Text = roleInfo.RoleName;
else
litGroupName.Text = roleInfo.RoleName;
txtDescription.Text = roleInfo.Description;
rdAccessTypePrivate.Checked = !roleInfo.IsPublic;
rdAccessTypePublic.Checked = roleInfo.IsPublic;
if (roleInfo.Settings.ContainsKey("ReviewMembers"))
{
chkMemberApproved.Checked = Convert.ToBoolean(roleInfo.Settings["ReviewMembers"].ToString());
}
imgGroup.Src = roleInfo.PhotoURL;
}
else
{
Response.Redirect(ModuleContext.NavigateUrl(TabId, "", false));
}
}
}
示例12: OnDeleteClick
/// -----------------------------------------------------------------------------
/// <summary>
/// cmdDelete_Click runs when the delete Button is clicked
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support
/// and localisation
/// </history>
/// -----------------------------------------------------------------------------
protected void OnDeleteClick(object sender, EventArgs e)
{
try
{
var objUser = new RoleController();
objUser.DeleteRole(_roleID, PortalSettings.PortalId);
//Clear Roles Cache
DataCache.RemoveCache("GetRoles");
Response.Redirect(Globals.NavigateURL());
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
示例13: AddGroupOwnerNotification
internal virtual Notification AddGroupOwnerNotification(string notificationTypeName, int tabId, int moduleId, RoleInfo group, UserInfo initiatingUser)
{
var notificationType = NotificationsController.Instance.GetNotificationType(notificationTypeName);
var tokenReplace = new GroupItemTokenReplace(group);
var subject = Localization.GetString(notificationTypeName + ".Subject", Constants.SharedResourcesPath);
var body = Localization.GetString(notificationTypeName + ".Body", Constants.SharedResourcesPath);
subject = subject.Replace("[DisplayName]", initiatingUser.DisplayName);
subject = subject.Replace("[ProfileUrl]", Globals.UserProfileURL(initiatingUser.UserID));
subject = tokenReplace.ReplaceGroupItemTokens(subject);
body = body.Replace("[DisplayName]", initiatingUser.DisplayName);
body = body.Replace("[ProfileUrl]", Globals.UserProfileURL(initiatingUser.UserID));
body = tokenReplace.ReplaceGroupItemTokens(body);
var roleCreator = UserController.GetUserById(group.PortalID, group.CreatedByUserID);
var roleOwners = new List<UserInfo>();
var rc = new RoleController();
foreach (UserInfo userInfo in rc.GetUsersByRoleName(group.PortalID, group.RoleName)) {
var userRoleInfo = rc.GetUserRole(group.PortalID, userInfo.UserID, group.RoleID);
if (userRoleInfo.IsOwner && userRoleInfo.UserID != group.CreatedByUserID)
{
roleOwners.Add(UserController.GetUserById(group.PortalID, userRoleInfo.UserID));
}
}
roleOwners.Add(roleCreator);
//Need to add from sender details
var notification = new Notification
{
NotificationTypeID = notificationType.NotificationTypeId,
Subject = subject,
Body = body,
IncludeDismissAction = true,
SenderUserID = initiatingUser.UserID,
Context = String.Format("{0}:{1}:{2}:{3}", tabId, moduleId, group.RoleID, initiatingUser.UserID)
};
NotificationsController.Instance.SendNotification(notification, initiatingUser.PortalID, null, roleOwners);
return notification;
}
示例14: CreateGroupFolder
public File CreateGroupFolder(int roleID, int portalID, UserInfo currentUser)
{
FileController ctrl = new FileController();
File rootGroupFolder = new File();
//rootGroupFolder.ChildCount = 0;
rootGroupFolder.CreatedByUserID = currentUser.UserID;
rootGroupFolder.CreatedByUserName = currentUser.DisplayName;
rootGroupFolder.CreatedDate = System.DateTime.Now;
rootGroupFolder.IsInTrash = false;
rootGroupFolder.IsFolder = true;
rootGroupFolder.ItemType = 0;
rootGroupFolder.LastModifiedByUserID = currentUser.UserID;
rootGroupFolder.LastModifiedByUserName = currentUser.DisplayName;
rootGroupFolder.LastModifiedDate = System.DateTime.Now;
RoleController ctrlRole = new RoleController();
RoleInfo role = ctrlRole.GetRole(roleID, portalID);
rootGroupFolder.Name = role.RoleName;
rootGroupFolder.ParentID = GetRootGroupsFolder(portalID, currentUser.UserID).ID;
rootGroupFolder.PortalID = portalID;
rootGroupFolder.RoleID = roleID;
ctrl.Create(rootGroupFolder);
Permission permission = new Permission();
permission.CanAddFiles = true;
permission.CanAddFolders = true;
permission.CanDelete = false;
permission.CanModify = false;
permission.CanModifyPermission = false;
permission.CanSee = true;
permission.FileID = rootGroupFolder.ID;
permission.ModuleID = 0;
permission.PortalID = portalID;
permission.RoleID = role.RoleID;
permission.RoleName = role.RoleName;
PermissionController ctrlPerm = new PermissionController();
ctrlPerm.Create(permission);
return rootGroupFolder;
}
示例15: ApproveGroup
public ActionResult ApproveGroup(int notificationId)
{
try
{
var recipient = InternalMessagingController.Instance.GetMessageRecipient(notificationId, UserInfo.UserID);
if (recipient == null) return Json(new { Result = "error" });
var notification = NotificationsController.Instance.GetNotification(notificationId);
ParseKey(notification.Context);
if (roleInfo == null)
{
return Json(new { Result = "error" });
}
if (!IsMod())
{
return Json(new { Result = "access denied" });
}
var roleController = new RoleController();
roleInfo.Status = RoleStatus.Approved;
roleController.UpdateRole(roleInfo);
var roleCreator = UserController.GetUserById(PortalSettings.PortalId, roleInfo.CreatedByUserID);
//Update the original creator's role
roleController.UpdateUserRole(PortalSettings.PortalId, roleCreator.UserID, roleInfo.RoleID, RoleStatus.Approved, true, false);
GroupUtilities.CreateJournalEntry(roleInfo, roleCreator);
var notifications = new Notifications();
var siteAdmin = UserController.GetUserById(PortalSettings.PortalId, PortalSettings.AdministratorId);
notifications.AddGroupNotification(Constants.GroupApprovedNotification, TabId, ModuleId, roleInfo, siteAdmin, new List<RoleInfo> { roleInfo });
NotificationsController.Instance.DeleteAllNotificationRecipients(notificationId);
return Json(new { Result = "success" });
}
catch (Exception exc)
{
DnnLog.Error(exc);
return Json(new { Result = "error" });
}
}