本文整理汇总了C#中UserInfo.SetPrivilegeLevel方法的典型用法代码示例。如果您正苦于以下问题:C# UserInfo.SetPrivilegeLevel方法的具体用法?C# UserInfo.SetPrivilegeLevel怎么用?C# UserInfo.SetPrivilegeLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserInfo
的用法示例。
在下文中一共展示了UserInfo.SetPrivilegeLevel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRegisteredCustomer
/// <summary>
/// Creates registered customer. Called when the "Create registered customer" button is pressed.
/// </summary>
private bool CreateRegisteredCustomer()
{
// Create a new user
UserInfo newUser = new UserInfo();
// Set the user properties
newUser.UserName = "My new user";
newUser.UserEnabled = true;
newUser.SetPrivilegeLevel(UserPrivilegeLevelEnum.Editor);
// Save the user
UserInfoProvider.SetUserInfo(newUser);
// Add user to current site
UserInfoProvider.AddUserToSite(newUser.UserName, SiteContext.CurrentSiteName);
// Create new customer object
CustomerInfo newCustomer = new CustomerInfo
{
CustomerFirstName = "",
CustomerLastName = "My new registered customer",
CustomerEmail = "[email protected]",
CustomerEnabled = true,
CustomerSiteID = SiteContext.CurrentSiteID,
CustomerUserID = newUser.UserID
};
// Create the registered customer
CustomerInfoProvider.SetCustomerInfo(newCustomer);
return true;
}
示例2: SaveNewUser
/// <summary>
/// Saves new user's data into DB.
/// </summary>
/// <returns>Returns ID of created user</returns>
protected int SaveNewUser()
{
UserInfo ui = new UserInfo();
// Load default values
FormHelper.LoadDefaultValues("cms.user", ui);
string emailAddress = txtEmailAddress.Text.Trim();
ui.PreferredCultureCode = "";
ui.Email = emailAddress;
ui.FirstName = "";
ui.FullName = txtFullName.Text;
ui.LastName = "";
ui.MiddleName = "";
ui.UserName = userName;
ui.Enabled = chkEnabled.Checked;
ui.IsExternal = false;
// Set privilege level, global admin may set all levels, rest only editor
UserPrivilegeLevelEnum privilegeLevel = (UserPrivilegeLevelEnum)drpPrivilegeLevel.Value.ToInteger(0);
if (CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)
|| (privilegeLevel == UserPrivilegeLevelEnum.None) || (privilegeLevel == UserPrivilegeLevelEnum.Editor))
{
ui.SetPrivilegeLevel(privilegeLevel);
}
// Check license limitations
if (SiteID > 0)
{
string errorMessage = String.Empty;
UserInfoProvider.CheckLicenseLimitation(ui, ref errorMessage);
if (!String.IsNullOrEmpty(errorMessage))
{
ShowError(errorMessage);
}
}
// Check whether email is unique if it is required
string siteName = SiteName;
bool assignUserToSite = chkAssignToSite.Checked && AllowAssignToWebsite;
if (assignUserToSite)
{
siteName = SiteContext.CurrentSiteName;
}
if (!UserInfoProvider.IsEmailUnique(emailAddress, siteName, 0))
{
ShowError(GetString("UserInfo.EmailAlreadyExist"));
return -1;
}
if (!error)
{
// Set password and save object
UserInfoProvider.SetPassword(ui, passStrength.Text);
// Add user to current site
if ((SiteID > 0) || assignUserToSite)
{
UserInfoProvider.AddUserToSite(ui.UserName, siteName);
}
return ui.UserID;
}
return -1;
}
示例3: btnOK_Click
//.........这里部分代码省略.........
// Display error message if catcha text is not valid
lblError.Visible = true;
lblError.Text = GetString("Webparts_Membership_RegistrationForm.captchaError");
return;
}
#endregion
#region "User properties"
ui = new UserInfo();
ui.PreferredCultureCode = "";
ui.Email = txtEmail.Text.Trim();
ui.FirstName = txtFirstName.Text.Trim();
ui.LastName = txtLastName.Text.Trim();
ui.FullName = UserInfoProvider.GetFullName(ui.FirstName, String.Empty, ui.LastName);
ui.MiddleName = "";
ui.UserMFRequired = chkUseMultiFactorAutentization.Checked;
// User name as put by user (no site prefix included)
String plainUserName = txtEmail.Text.Trim();
ui.UserName = plainUserName;
// Ensure site prefixes
if (UserInfoProvider.UserNameSitePrefixEnabled(siteName))
{
ui.UserName = UserInfoProvider.EnsureSitePrefixUserName(txtEmail.Text.Trim(), si);
}
ui.Enabled = EnableUserAfterRegistration;
ui.UserURLReferrer = MembershipContext.AuthenticatedUser.URLReferrer;
ui.UserCampaign = AnalyticsHelper.Campaign;
ui.SetPrivilegeLevel(UserPrivilegeLevelEnum.None);
ui.UserSettings.UserRegistrationInfo.IPAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
ui.UserSettings.UserRegistrationInfo.Agent = HttpContext.Current.Request.UserAgent;
// Check whether confirmation is required
bool requiresConfirmation = SettingsKeyInfoProvider.GetBoolValue(siteName + ".CMSRegistrationEmailConfirmation");
bool requiresAdminApprove = false;
if (!requiresConfirmation)
{
// If confirmation is not required check whether administration approval is reqiures
if ((requiresAdminApprove = SettingsKeyInfoProvider.GetBoolValue(siteName + ".CMSRegistrationAdministratorApproval")))
{
ui.Enabled = false;
ui.UserSettings.UserWaitingForApproval = true;
}
}
else
{
// EnableUserAfterRegistration is overrided by requiresConfirmation - user needs to be confirmed before enable
ui.Enabled = false;
}
// Set user's starting alias path
if (!String.IsNullOrEmpty(StartingAliasPath))
{
ui.UserStartingAliasPath = MacroResolver.ResolveCurrentPath(StartingAliasPath);
}
#endregion
#region "Reserved names"
开发者ID:arvind-web-developer,项目名称:csharp-projects-Jemena-Kentico-CMS,代码行数:67,代码来源:RegistrationForm.ascx.cs