Completes: U4-5810 Remove umbraco.providers assembly and classes - old membership providers
This commit is contained in:
@@ -602,10 +602,6 @@
|
||||
<Project>{511F6D8D-7717-440A-9A57-A507E9A8B27F}</Project>
|
||||
<Name>umbraco.interfaces</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\umbraco.providers\umbraco.providers.csproj">
|
||||
<Project>{d7636876-0756-43cb-a192-138c6f0d5e42}</Project>
|
||||
<Name>umbraco.providers</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Umbraco.Web\Umbraco.Web.csproj">
|
||||
<Project>{651E1350-91B6-44B7-BD60-7207006D7003}</Project>
|
||||
<Name>Umbraco.Web</Name>
|
||||
|
||||
@@ -289,10 +289,6 @@
|
||||
<Project>{651E1350-91B6-44B7-BD60-7207006D7003}</Project>
|
||||
<Name>Umbraco.Web</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\umbraco.providers\umbraco.providers.csproj">
|
||||
<Project>{D7636876-0756-43CB-A192-138C6F0D5E42}</Project>
|
||||
<Name>umbraco.providers</Name>
|
||||
</ProjectReference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="UrlRewritingNet.UrlRewriter">
|
||||
<HintPath>..\packages\UrlRewritingNet.UrlRewriter.2.0.60829.1\lib\UrlRewritingNet.UrlRewriter.dll</HintPath>
|
||||
|
||||
@@ -1,26 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Controllers;
|
||||
using System.Web.Security;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Mapping;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Web.WebApi;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using umbraco.providers;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
});
|
||||
|
||||
//check if there's an approval field
|
||||
var provider = membersProvider as global::umbraco.providers.members.UmbracoMembershipProvider;
|
||||
var provider = membersProvider as IUmbracoMemberTypeMembershipProvider;
|
||||
if (member.HasIdentity == false && provider != null)
|
||||
{
|
||||
var approvedField = provider.ApprovedPropertyTypeAlias;
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using umbraco;
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.businesslogic.Exceptions;
|
||||
using umbraco.providers;
|
||||
using GlobalSettings = Umbraco.Core.Configuration.GlobalSettings;
|
||||
using Member = umbraco.cms.businesslogic.member.Member;
|
||||
using User = umbraco.BusinessLogic.User;
|
||||
|
||||
namespace Umbraco.Web.Security
|
||||
|
||||
@@ -253,10 +253,6 @@
|
||||
<Project>{511F6D8D-7717-440A-9A57-A507E9A8B27F}</Project>
|
||||
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\umbraco.providers\umbraco.providers.csproj">
|
||||
<Project>{D7636876-0756-43CB-A192-138C6F0D5E42}</Project>
|
||||
<Name>umbraco.providers</Name>
|
||||
</ProjectReference>
|
||||
<Reference Include="UrlRewritingNet.UrlRewriter, Version=2.0.60829.1, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\UrlRewritingNet.UrlRewriter.2.0.60829.1\lib\UrlRewritingNet.UrlRewriter.dll</HintPath>
|
||||
|
||||
@@ -9,22 +9,16 @@ using System.Web.UI;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Security;
|
||||
using umbraco.BasePages;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.businesslogic.Exceptions;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
using umbraco.cms.businesslogic.propertytype;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using umbraco.controls;
|
||||
using umbraco.presentation.channels.businesslogic;
|
||||
using umbraco.uicontrols;
|
||||
using umbraco.providers;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("umbraco.providers")]
|
||||
[assembly: AssemblyDescription("Core assembly containing umbraco specific membership providers")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyProduct("Umbraco CMS")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5b071553-1474-44a0-9cad-52b3f3255639")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Umbraco.Tests")]
|
||||
@@ -1,230 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.Web.Hosting;
|
||||
using System.Configuration.Provider;
|
||||
|
||||
namespace umbraco.providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Security Helper Methods
|
||||
/// </summary>
|
||||
[ObsoleteAttribute("This clas is obsolete and wil be removed along with the legacy Membership Provider.", false)]
|
||||
internal class SecUtility
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the boolean value.
|
||||
/// </summary>
|
||||
/// <param name="config">The config.</param>
|
||||
/// <param name="valueName">Name of the value.</param>
|
||||
/// <param name="defaultValue">if set to <c>true</c> [default value].</param>
|
||||
/// <returns></returns>
|
||||
internal static bool GetBooleanValue(NameValueCollection config, string valueName, bool defaultValue)
|
||||
{
|
||||
bool flag;
|
||||
string str = config[valueName];
|
||||
if (str == null)
|
||||
return defaultValue;
|
||||
|
||||
if (!bool.TryParse(str, out flag))
|
||||
{
|
||||
throw new ProviderException("Value must be boolean.");
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the array parameter.
|
||||
/// </summary>
|
||||
/// <param name="param">The param.</param>
|
||||
/// <param name="checkForNull">if set to <c>true</c> [check for null].</param>
|
||||
/// <param name="checkIfEmpty">if set to <c>true</c> [check if empty].</param>
|
||||
/// <param name="checkForCommas">if set to <c>true</c> [check for commas].</param>
|
||||
/// <param name="maxSize">Size of the max.</param>
|
||||
/// <param name="paramName">Name of the param.</param>
|
||||
internal static void CheckArrayParameter(ref string[] param, bool checkForNull, bool checkIfEmpty, bool checkForCommas, int maxSize, string paramName)
|
||||
{
|
||||
if (param == null)
|
||||
{
|
||||
throw new ArgumentNullException(paramName);
|
||||
}
|
||||
if (param.Length < 1)
|
||||
{
|
||||
throw new ArgumentException("Parameter array empty.");
|
||||
}
|
||||
Hashtable hashtable = new Hashtable(param.Length);
|
||||
for (int i = param.Length - 1; i >= 0; i--)
|
||||
{
|
||||
CheckParameter(ref param[i], checkForNull, checkIfEmpty, checkForCommas, maxSize, paramName + "[ " + i.ToString(CultureInfo.InvariantCulture) + " ]");
|
||||
if (hashtable.Contains(param[i]))
|
||||
{
|
||||
throw new ArgumentException("Parameter duplicate array element");
|
||||
}
|
||||
hashtable.Add(param[i], param[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the parameter.
|
||||
/// </summary>
|
||||
/// <param name="param">The param.</param>
|
||||
/// <param name="checkForNull">if set to <c>true</c> [check for null].</param>
|
||||
/// <param name="checkIfEmpty">if set to <c>true</c> [check if empty].</param>
|
||||
/// <param name="checkForCommas">if set to <c>true</c> [check for commas].</param>
|
||||
/// <param name="maxSize">Size of the max.</param>
|
||||
/// <param name="paramName">Name of the param.</param>
|
||||
internal static void CheckParameter(ref string param, bool checkForNull, bool checkIfEmpty, bool checkForCommas, int maxSize, string paramName)
|
||||
{
|
||||
if (param == null)
|
||||
{
|
||||
if (checkForNull)
|
||||
{
|
||||
throw new ArgumentNullException(paramName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
param = param.Trim();
|
||||
if (checkIfEmpty && (param.Length < 1))
|
||||
{
|
||||
throw new ProviderException("Parameter can not be empty.");
|
||||
}
|
||||
if ((maxSize > 0) && (param.Length > maxSize))
|
||||
{
|
||||
throw new ProviderException("Parameter too long.");
|
||||
}
|
||||
if (checkForCommas && param.Contains(","))
|
||||
{
|
||||
throw new ProviderException("Parameter cannot contain comman.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the password parameter.
|
||||
/// </summary>
|
||||
/// <param name="param">The param.</param>
|
||||
/// <param name="maxSize">Size of the max.</param>
|
||||
/// <param name="paramName">Name of the param.</param>
|
||||
internal static void CheckPasswordParameter(ref string param, int maxSize, string paramName)
|
||||
{
|
||||
if (param == null)
|
||||
{
|
||||
throw new ArgumentNullException(paramName);
|
||||
}
|
||||
if (param.Length < 1)
|
||||
{
|
||||
throw new ProviderException("Parameter can not be empty");
|
||||
}
|
||||
if ((maxSize > 0) && (param.Length > maxSize))
|
||||
{
|
||||
throw new ProviderException("Parameter too long");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the default app.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static string GetDefaultAppName()
|
||||
{
|
||||
try
|
||||
{
|
||||
string applicationVirtualPath = HostingEnvironment.ApplicationVirtualPath;
|
||||
if (string.IsNullOrEmpty(applicationVirtualPath))
|
||||
{
|
||||
return "/";
|
||||
}
|
||||
return applicationVirtualPath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "/";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the int value.
|
||||
/// </summary>
|
||||
/// <param name="config">The config.</param>
|
||||
/// <param name="valueName">Name of the value.</param>
|
||||
/// <param name="defaultValue">The default value.</param>
|
||||
/// <param name="zeroAllowed">if set to <c>true</c> [zero allowed].</param>
|
||||
/// <param name="maxValueAllowed">The max value allowed.</param>
|
||||
/// <returns></returns>
|
||||
internal static int GetIntValue(NameValueCollection config, string valueName, int defaultValue, bool zeroAllowed, int maxValueAllowed)
|
||||
{
|
||||
int num;
|
||||
string s = config[valueName];
|
||||
if (s == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (!int.TryParse(s, out num))
|
||||
{
|
||||
if (zeroAllowed)
|
||||
{
|
||||
throw new ProviderException("Value must be non negative integer");
|
||||
}
|
||||
throw new ProviderException("Value must be positive integer");
|
||||
}
|
||||
if (zeroAllowed && (num < 0))
|
||||
{
|
||||
throw new ProviderException("Value must be non negativeinteger");
|
||||
}
|
||||
if (!zeroAllowed && (num <= 0))
|
||||
{
|
||||
throw new ProviderException("Value must be positive integer");
|
||||
}
|
||||
if ((maxValueAllowed > 0) && (num > maxValueAllowed))
|
||||
{
|
||||
throw new ProviderException("Value too big");
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the parameter.
|
||||
/// </summary>
|
||||
/// <param name="param">The param.</param>
|
||||
/// <param name="checkForNull">if set to <c>true</c> [check for null].</param>
|
||||
/// <param name="checkIfEmpty">if set to <c>true</c> [check if empty].</param>
|
||||
/// <param name="checkForCommas">if set to <c>true</c> [check for commas].</param>
|
||||
/// <param name="maxSize">Size of the max.</param>
|
||||
/// <returns></returns>
|
||||
internal static bool ValidateParameter(ref string param, bool checkForNull, bool checkIfEmpty, bool checkForCommas, int maxSize)
|
||||
{
|
||||
if (param == null)
|
||||
{
|
||||
return !checkForNull;
|
||||
}
|
||||
param = param.Trim();
|
||||
return (((!checkIfEmpty || (param.Length >= 1)) && ((maxSize <= 0) || (param.Length <= maxSize))) && (!checkForCommas || !param.Contains(",")));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Validates the password parameter.
|
||||
/// </summary>
|
||||
/// <param name="param">The param.</param>
|
||||
/// <param name="maxSize">Size of the max.</param>
|
||||
/// <returns></returns>
|
||||
internal static bool ValidatePasswordParameter(ref string param, int maxSize)
|
||||
{
|
||||
if (param == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (param.Length < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((maxSize > 0) && (param.Length > maxSize))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,545 +0,0 @@
|
||||
#region namespace
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Security;
|
||||
using System.Configuration;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Security;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Web.Util;
|
||||
using System.Configuration.Provider;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace umbraco.providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Membership Provider for Umbraco Users (User authentication for Umbraco Backend CMS)
|
||||
/// </summary>
|
||||
[Obsolete("This has been superceded by Umbraco.Web.Security.Providers.UsersMembershipProvider")]
|
||||
public class UsersMembershipProvider : MembershipProviderBase, IUsersMembershipProvider
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Override to maintain backwards compatibility with 0 required non-alphanumeric chars
|
||||
/// </summary>
|
||||
public override int DefaultMinNonAlphanumericChars
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override to maintain backwards compatibility with only 4 required length
|
||||
/// </summary>
|
||||
public override int DefaultMinPasswordLength
|
||||
{
|
||||
get { return 4; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override to maintain backwards compatibility
|
||||
/// </summary>
|
||||
public override bool DefaultUseLegacyEncoding
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For backwards compatibility, this provider supports this option
|
||||
/// </summary>
|
||||
public override bool AllowManuallyChangingPassword
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
|
||||
{
|
||||
if (config == null) throw new ArgumentNullException("config");
|
||||
if (string.IsNullOrEmpty(name)) name = UmbracoSettings.DefaultBackofficeProvider;
|
||||
|
||||
base.Initialize(name, config);
|
||||
}
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Processes a request to update the password for a membership user.
|
||||
/// </summary>
|
||||
/// <param name="username">The user to update the password for.</param>
|
||||
/// <param name="oldPassword">The current password for the specified user.</param>
|
||||
/// <param name="newPassword">The new password for the specified user.</param>
|
||||
/// <returns>
|
||||
/// true if the password was updated successfully; otherwise, false.
|
||||
/// </returns>
|
||||
protected override bool PerformChangePassword(string username, string oldPassword, string newPassword)
|
||||
{
|
||||
//NOTE: due to backwards compatibilty reasons (and UX reasons), this provider doesn't care about the old password and
|
||||
// allows simply setting the password manually so we don't really care about the old password.
|
||||
// This is allowed based on the overridden AllowManuallyChangingPassword option.
|
||||
|
||||
var user = new User(username);
|
||||
//encrypt/hash the new one
|
||||
string salt;
|
||||
var encodedPassword = EncryptOrHashNewPassword(newPassword, out salt);
|
||||
|
||||
//Yes, it's true, this actually makes a db call to set the password
|
||||
user.Password = FormatPasswordForStorage(encodedPassword, salt);
|
||||
//call this just for fun.
|
||||
user.Save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes a request to update the password question and answer for a membership user.
|
||||
/// </summary>
|
||||
/// <param name="username">The user to change the password question and answer for.</param>
|
||||
/// <param name="password">The password for the specified user.</param>
|
||||
/// <param name="newPasswordQuestion">The new password question for the specified user.</param>
|
||||
/// <param name="newPasswordAnswer">The new password answer for the specified user.</param>
|
||||
/// <returns>
|
||||
/// true if the password question and answer are updated successfully; otherwise, false.
|
||||
/// </returns>
|
||||
protected override bool PerformChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new membership user to the data source.
|
||||
/// </summary>
|
||||
/// <param name="username">The user name for the new user.</param>
|
||||
/// <param name="password">The password for the new user.</param>
|
||||
/// <param name="email">The e-mail address for the new user.</param>
|
||||
/// <param name="passwordQuestion">The password question for the new user.</param>
|
||||
/// <param name="passwordAnswer">The password answer for the new user</param>
|
||||
/// <param name="isApproved">Whether or not the new user is approved to be validated.</param>
|
||||
/// <param name="providerUserKey">The unique identifier from the membership data source for the user.</param>
|
||||
/// <param name="status">A <see cref="T:System.Web.Security.MembershipCreateStatus"></see> enumeration value indicating whether the user was created successfully.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Web.Security.MembershipUser"></see> object populated with the information for the newly created user.
|
||||
/// </returns>
|
||||
protected override MembershipUser PerformCreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
|
||||
{
|
||||
|
||||
// TODO: Does umbraco allow duplicate emails??
|
||||
//if (RequiresUniqueEmail && !string.IsNullOrEmpty(GetUserNameByEmail(email)))
|
||||
//{
|
||||
// status = MembershipCreateStatus.DuplicateEmail;
|
||||
// return null;
|
||||
//}
|
||||
|
||||
var u = GetUser(username, false) as UsersMembershipUser;
|
||||
if (u == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get the usertype of the current user
|
||||
var ut = UserType.GetUserType(1);
|
||||
if (BasePages.UmbracoEnsuredPage.CurrentUser != null)
|
||||
{
|
||||
ut = BasePages.UmbracoEnsuredPage.CurrentUser.UserType;
|
||||
}
|
||||
|
||||
//ensure the password is encrypted/hashed
|
||||
string salt;
|
||||
var encodedPass = EncryptOrHashNewPassword(password, out salt);
|
||||
|
||||
User.MakeNew(username, username, FormatPasswordForStorage(encodedPass, salt), email, ut);
|
||||
|
||||
status = MembershipCreateStatus.Success;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
status = MembershipCreateStatus.ProviderError;
|
||||
}
|
||||
return GetUser(username, false);
|
||||
}
|
||||
|
||||
status = MembershipCreateStatus.DuplicateUserName;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a user from the membership data source.
|
||||
/// </summary>
|
||||
/// <param name="username">The name of the user to delete.</param>
|
||||
/// <param name="deleteAllRelatedData">true to delete data related to the user from the database; false to leave data related to the user in the database.</param>
|
||||
/// <returns>
|
||||
/// true if the user was successfully deleted; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool DeleteUser(string username, bool deleteAllRelatedData)
|
||||
{
|
||||
try
|
||||
{
|
||||
User user = new User(username);
|
||||
user.delete();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of membership users where the e-mail address contains the specified e-mail address to match.
|
||||
/// </summary>
|
||||
/// <param name="emailToMatch">The e-mail address to search for.</param>
|
||||
/// <param name="pageIndex">The index of the page of results to return. pageIndex is zero-based.</param>
|
||||
/// <param name="pageSize">The size of the page of results to return.</param>
|
||||
/// <param name="totalRecords">The total number of matched users.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Web.Security.MembershipUserCollection"></see> collection that contains a page of pageSize<see cref="T:System.Web.Security.MembershipUser"></see> objects beginning at the page specified by pageIndex.
|
||||
/// </returns>
|
||||
public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
|
||||
{
|
||||
var counter = 0;
|
||||
var startIndex = pageSize * pageIndex;
|
||||
var endIndex = startIndex + pageSize - 1;
|
||||
var usersList = new MembershipUserCollection();
|
||||
var usersArray = User.getAllByEmail(emailToMatch);
|
||||
totalRecords = usersArray.Length;
|
||||
|
||||
foreach (var user in usersArray)
|
||||
{
|
||||
if (counter >= startIndex)
|
||||
usersList.Add(ConvertToMembershipUser(user));
|
||||
if (counter >= endIndex) break;
|
||||
counter++;
|
||||
}
|
||||
return usersList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of membership users where the user name contains the specified user name to match.
|
||||
/// </summary>
|
||||
/// <param name="usernameToMatch">The user name to search for.</param>
|
||||
/// <param name="pageIndex">The index of the page of results to return. pageIndex is zero-based.</param>
|
||||
/// <param name="pageSize">The size of the page of results to return.</param>
|
||||
/// <param name="totalRecords">The total number of matched users.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Web.Security.MembershipUserCollection"></see> collection that contains a page of pageSize<see cref="T:System.Web.Security.MembershipUser"></see> objects beginning at the page specified by pageIndex.
|
||||
/// </returns>
|
||||
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
|
||||
{
|
||||
var counter = 0;
|
||||
var startIndex = pageSize * pageIndex;
|
||||
var endIndex = startIndex + pageSize - 1;
|
||||
var usersList = new MembershipUserCollection();
|
||||
var usersArray = User.GetAllByLoginName(usernameToMatch, true).ToArray();
|
||||
totalRecords = usersArray.Length;
|
||||
|
||||
foreach (var user in usersArray)
|
||||
{
|
||||
if (counter >= startIndex)
|
||||
usersList.Add(ConvertToMembershipUser(user));
|
||||
if (counter >= endIndex) break;
|
||||
counter++;
|
||||
}
|
||||
return usersList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all the users in the data source in pages of data.
|
||||
/// </summary>
|
||||
/// <param name="pageIndex">The index of the page of results to return. pageIndex is zero-based.</param>
|
||||
/// <param name="pageSize">The size of the page of results to return.</param>
|
||||
/// <param name="totalRecords">The total number of matched users.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Web.Security.MembershipUserCollection"></see> collection that contains a page of pageSize<see cref="T:System.Web.Security.MembershipUser"></see> objects beginning at the page specified by pageIndex.
|
||||
/// </returns>
|
||||
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
|
||||
{
|
||||
var counter = 0;
|
||||
var startIndex = pageSize * pageIndex;
|
||||
var endIndex = startIndex + pageSize - 1;
|
||||
var usersList = new MembershipUserCollection();
|
||||
var usersArray = User.getAll();
|
||||
totalRecords = usersArray.Length;
|
||||
|
||||
foreach (User user in usersArray)
|
||||
{
|
||||
if (counter >= startIndex)
|
||||
usersList.Add(ConvertToMembershipUser(user));
|
||||
if (counter >= endIndex) break;
|
||||
counter++;
|
||||
}
|
||||
return usersList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of users currently accessing the application.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The number of users currently accessing the application.
|
||||
/// </returns>
|
||||
public override int GetNumberOfUsersOnline()
|
||||
{
|
||||
var fromDate = DateTime.Now.AddMinutes(-Membership.UserIsOnlineTimeWindow);
|
||||
return Log.Instance.GetLogItems(LogTypes.Login, fromDate).Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the password for the specified user name from the data source. This is - for security - not
|
||||
/// supported for Umbraco Users and an exception will be thrown
|
||||
/// </summary>
|
||||
/// <param name="username">The user to retrieve the password for.</param>
|
||||
/// <param name="answer">The password answer for the user.</param>
|
||||
/// <returns>
|
||||
/// The password for the specified user name.
|
||||
/// </returns>
|
||||
protected override string PerformGetPassword(string username, string answer)
|
||||
{
|
||||
var found = User.GetAllByLoginName(username, false).ToArray();
|
||||
if (found == null || found.Any() == false)
|
||||
{
|
||||
throw new MembershipPasswordException("The supplied user is not found");
|
||||
}
|
||||
|
||||
// check if user is locked out
|
||||
if (found.First().NoConsole)
|
||||
{
|
||||
throw new MembershipPasswordException("The supplied user is locked out");
|
||||
}
|
||||
|
||||
if (RequiresQuestionAndAnswer)
|
||||
{
|
||||
throw new NotImplementedException("Question/answer is not supported with this membership provider");
|
||||
}
|
||||
|
||||
var decodedPassword = DecryptPassword(found.First().GetPassword());
|
||||
|
||||
return decodedPassword;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets information from the data source for a user. Provides an option to update the last-activity date/time stamp for the user.
|
||||
/// </summary>
|
||||
/// <param name="username">The name of the user to get information for.</param>
|
||||
/// <param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Web.Security.MembershipUser"></see> object populated with the specified user's information from the data source.
|
||||
/// </returns>
|
||||
public override MembershipUser GetUser(string username, bool userIsOnline)
|
||||
{
|
||||
var userId = User.getUserId(username);
|
||||
if (userId == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var user = new User(userId);
|
||||
|
||||
//We need to log this since it's the only way we can determine the number of users online
|
||||
Log.Add(LogTypes.Login, user, -1, "User " + username + " has logged in");
|
||||
|
||||
return (userId != -1) ? ConvertToMembershipUser(user) : null;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets information from the data source for a user based on the unique identifier for the membership user. Provides an option to update the last-activity date/time stamp for the user.
|
||||
/// </summary>
|
||||
/// <param name="providerUserKey">The unique identifier for the membership user to get information for.</param>
|
||||
/// <param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Web.Security.MembershipUser"></see> object populated with the specified user's information from the data source.
|
||||
/// </returns>
|
||||
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
|
||||
{
|
||||
var user = new User(Convert.ToInt32(providerUserKey));
|
||||
//We need to log this since it's the only way we can determine the number of users online
|
||||
Log.Add(LogTypes.Login, user, -1, "User " + user.LoginName + " has logged in");
|
||||
return ConvertToMembershipUser(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user name associated with the specified e-mail address.
|
||||
/// </summary>
|
||||
/// <param name="email">The e-mail address to search for.</param>
|
||||
/// <returns>
|
||||
/// The user name associated with the specified e-mail address. If no match is found, return null.
|
||||
/// </returns>
|
||||
public override string GetUserNameByEmail(string email)
|
||||
{
|
||||
var found = User.getAllByEmail(email.Trim().ToLower(), true);
|
||||
if (found == null || found.Any() == false)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return found.First().LoginName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets a user's password to a new, automatically generated password.
|
||||
/// </summary>
|
||||
/// <param name="username">The user to reset the password for.</param>
|
||||
/// <param name="answer">The password answer for the specified user.</param>
|
||||
/// <returns>The new password for the specified user.</returns>
|
||||
protected override string PerformResetPassword(string username, string answer, string generatedPassword)
|
||||
{
|
||||
//TODO: This should be here - but how do we update failure count in this provider??
|
||||
//if (answer == null && RequiresQuestionAndAnswer)
|
||||
//{
|
||||
// UpdateFailureCount(username, "passwordAnswer");
|
||||
|
||||
// throw new ProviderException("Password answer required for password reset.");
|
||||
//}
|
||||
|
||||
var found = User.GetAllByLoginName(username, false).ToArray();
|
||||
if (found == null || found.Any() == false)
|
||||
throw new MembershipPasswordException("The supplied user is not found");
|
||||
|
||||
var user = found.First();
|
||||
|
||||
//Yes, it's true, this actually makes a db call to set the password
|
||||
string salt;
|
||||
var encPass = EncryptOrHashNewPassword(generatedPassword, out salt);
|
||||
user.Password = FormatPasswordForStorage(encPass, salt);
|
||||
//call this just for fun.
|
||||
user.Save();
|
||||
|
||||
return generatedPassword;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears a lock so that the membership user can be validated.
|
||||
/// </summary>
|
||||
/// <param name="userName">The membership user to clear the lock status for.</param>
|
||||
/// <returns>
|
||||
/// true if the membership user was successfully unlocked; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool UnlockUser(string userName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = new User(userName)
|
||||
{
|
||||
NoConsole = false
|
||||
};
|
||||
user.Save();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates information about a user in the data source.
|
||||
/// </summary>
|
||||
/// <param name="user">A <see cref="T:System.Web.Security.MembershipUser"></see> object that represents the user to update and the updated information for the user.</param>
|
||||
public override void UpdateUser(MembershipUser user)
|
||||
{
|
||||
var found = User.GetAllByLoginName(user.UserName, false).ToArray();
|
||||
if (found == null || found.Any() == false)
|
||||
{
|
||||
throw new ProviderException("The supplied user is not found");
|
||||
}
|
||||
|
||||
var m = found.First();
|
||||
if (RequiresUniqueEmail && user.Email.Trim().IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
var byEmail = User.getAllByEmail(user.Email, true);
|
||||
if (byEmail.Count(x => x.Id != m.Id) > 0)
|
||||
{
|
||||
throw new ProviderException(string.Format("A member with the email '{0}' already exists", user.Email));
|
||||
}
|
||||
}
|
||||
|
||||
var typedUser = user as UsersMembershipUser;
|
||||
if (typedUser == null)
|
||||
{
|
||||
// update approve status
|
||||
// update lock status
|
||||
// TODO: Update last lockout time
|
||||
// TODO: update comment
|
||||
User.Update(m.Id, user.Email, user.IsApproved == false, user.IsLockedOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
//This keeps compatibility - even though this logic to update name and user type should not exist here
|
||||
User.Update(m.Id, typedUser.FullName.Trim(), typedUser.UserName, typedUser.Email, user.IsApproved == false, user.IsLockedOut, typedUser.UserType);
|
||||
}
|
||||
|
||||
m.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the specified user name and password exist in the data source.
|
||||
/// </summary>
|
||||
/// <param name="username">The name of the user to validate.</param>
|
||||
/// <param name="password">The password for the specified user.</param>
|
||||
/// <returns>
|
||||
/// true if the specified username and password are valid; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool ValidateUser(string username, string password)
|
||||
{
|
||||
var userId = User.getUserId(username);
|
||||
if (userId != -1)
|
||||
{
|
||||
var user = User.GetUser(userId);
|
||||
if (user != null)
|
||||
{
|
||||
if (user.Disabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return CheckPassword(password, user.Password);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Encodes the password.
|
||||
/// </summary>
|
||||
/// <param name="password">The password.</param>
|
||||
/// <returns>The encoded password.</returns>
|
||||
[Obsolete("Do not use this, it is the legacy way to encode a password")]
|
||||
public string EncodePassword(string password)
|
||||
{
|
||||
return base.LegacyEncodePassword(password);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unencode password.
|
||||
/// </summary>
|
||||
/// <param name="encodedPassword">The encoded password.</param>
|
||||
/// <returns>The unencoded password.</returns>
|
||||
[Obsolete("Do not use this, it is the legacy way to decode a password")]
|
||||
public string UnEncodePassword(string encodedPassword)
|
||||
{
|
||||
return LegacyUnEncodePassword(encodedPassword);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts to membership user.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns></returns>
|
||||
private UsersMembershipUser ConvertToMembershipUser(User user)
|
||||
{
|
||||
if (user == null) return null;
|
||||
return new UsersMembershipUser(base.Name, user.LoginName, user.Id, user.Email,
|
||||
string.Empty, string.Empty, true, user.Disabled,
|
||||
DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now,
|
||||
DateTime.Now, user.Name, user.Language, user.UserType);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
#region namespace
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web.Security;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Data;
|
||||
#endregion
|
||||
|
||||
namespace umbraco.providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper for the umbraco.BusinessLogic.User class.
|
||||
/// </summary>
|
||||
[Obsolete("This class is used by the legacy user's membership provider which is also obsolete, this shouldn't be referenced directly in code, the standard .Net MembershipUser base class object should be referenced instead.")]
|
||||
public class UsersMembershipUser : MembershipUser
|
||||
{
|
||||
#region Fields and Properties
|
||||
private string _FullName;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the full name.
|
||||
/// </summary>
|
||||
/// <value>The full name.</value>
|
||||
public string FullName
|
||||
{
|
||||
get { return _FullName; }
|
||||
set { _FullName = value; }
|
||||
}
|
||||
private string _Language;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the language.
|
||||
/// </summary>
|
||||
/// <value>The language.</value>
|
||||
public string Language
|
||||
{
|
||||
get { return _Language; }
|
||||
set { _Language = value; }
|
||||
}
|
||||
private UserType _UserType;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the user.
|
||||
/// </summary>
|
||||
/// <value>The type of the user.</value>
|
||||
public UserType UserType
|
||||
{
|
||||
get { return _UserType; }
|
||||
set { _UserType = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoMembershipUser"/> class.
|
||||
/// </summary>
|
||||
protected UsersMembershipUser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoMembershipUser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="providerName">Name of the provider.</param>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="providerUserKey">The provider user key.</param>
|
||||
/// <param name="email">The email.</param>
|
||||
/// <param name="passwordQuestion">The password question.</param>
|
||||
/// <param name="comment">The comment.</param>
|
||||
/// <param name="isApproved">if set to <c>true</c> [is approved].</param>
|
||||
/// <param name="isLockedOut">if set to <c>true</c> [is locked out].</param>
|
||||
/// <param name="creationDate">The creation date.</param>
|
||||
/// <param name="lastLoginDate">The last login date.</param>
|
||||
/// <param name="lastActivityDate">The last activity date.</param>
|
||||
/// <param name="lastPasswordChangedDate">The last password changed date.</param>
|
||||
/// <param name="lastLockoutDate">The last lockout date.</param>
|
||||
/// <param name="fullName">The full name.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <param name="userType">Type of the user.</param>
|
||||
public UsersMembershipUser(string providerName, string name, object providerUserKey, string email,
|
||||
string passwordQuestion, string comment, bool isApproved, bool isLockedOut,
|
||||
DateTime creationDate, DateTime lastLoginDate, DateTime lastActivityDate, DateTime lastPasswordChangedDate,
|
||||
DateTime lastLockoutDate, string fullName, string language, UserType userType )
|
||||
: base( providerName, name, providerUserKey, email, passwordQuestion, comment, isApproved, isLockedOut,
|
||||
creationDate, lastLoginDate, lastActivityDate, lastPasswordChangedDate, lastLockoutDate)
|
||||
{
|
||||
_FullName = fullName;
|
||||
_UserType = userType;
|
||||
_Language = language;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
#region namespace
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Configuration.Provider;
|
||||
using System.Web.Security;
|
||||
using System.Collections.Specialized;
|
||||
#endregion
|
||||
|
||||
namespace umbraco.providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Roles Provider for Umbraco
|
||||
/// </summary>
|
||||
[Obsolete("This is not used and no methods are implemented, it will be removed in future versions")]
|
||||
public class UsersRoleProvider : RoleProvider
|
||||
{
|
||||
#region
|
||||
private string _applicationName;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the application to store and retrieve role information for.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>The name of the application to store and retrieve role information for.</returns>
|
||||
public override string ApplicationName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _applicationName;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
throw new ProviderException("ApplicationName cannot be empty.");
|
||||
|
||||
if (value.Length > 0x100)
|
||||
throw new ProviderException("Provider application name too long.");
|
||||
|
||||
_applicationName = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Initialization Method
|
||||
/// <summary>
|
||||
/// Initializes the provider.
|
||||
/// </summary>
|
||||
/// <param name="name">The friendly name of the provider.</param>
|
||||
/// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param>
|
||||
/// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception>
|
||||
/// <exception cref="T:System.InvalidOperationException">An attempt is made to call
|
||||
/// <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider
|
||||
/// after the provider has already been initialized.</exception>
|
||||
/// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception>
|
||||
public override void Initialize(string name, NameValueCollection config)
|
||||
{
|
||||
// Initialize values from web.config
|
||||
if (config == null) throw new ArgumentNullException("config");
|
||||
|
||||
if (name == null || name.Length == 0) name = "UmbracoRoleProvider";
|
||||
|
||||
if (String.IsNullOrEmpty(config["description"]))
|
||||
{
|
||||
config.Remove("description");
|
||||
config.Add("description", "Umbraco Role provider");
|
||||
}
|
||||
|
||||
// Initialize the abstract base class.
|
||||
base.Initialize(name, config);
|
||||
|
||||
this._applicationName = config["applicationName"];
|
||||
if (string.IsNullOrEmpty(this._applicationName))
|
||||
this._applicationName = SecUtility.GetDefaultAppName();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Adds the specified user names to the specified roles for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="usernames">A string array of user names to be added to the specified roles.</param>
|
||||
/// <param name="roleNames">A string array of the role names to add the specified user names to.</param>
|
||||
public override void AddUsersToRoles(string[] usernames, string[] roleNames)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new role to the data source for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role to create.</param>
|
||||
public override void CreateRole(string roleName)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a role from the data source for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role to delete.</param>
|
||||
/// <param name="throwOnPopulatedRole">If true, throw an exception if roleName has one or more members and do not delete roleName.</param>
|
||||
/// <returns>
|
||||
/// true if the role was successfully deleted; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an array of user names in a role where the user name contains the specified user name to match.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The role to search in.</param>
|
||||
/// <param name="usernameToMatch">The user name to search for.</param>
|
||||
/// <returns>
|
||||
/// A string array containing the names of all the users where the user name matches usernameToMatch and the user is a member of the specified role.
|
||||
/// </returns>
|
||||
public override string[] FindUsersInRole(string roleName, string usernameToMatch)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all the roles for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A string array containing the names of all the roles stored in the data source for the configured applicationName.
|
||||
/// </returns>
|
||||
public override string[] GetAllRoles()
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of the roles that a specified user is in for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="username">The user to return a list of roles for.</param>
|
||||
/// <returns>
|
||||
/// A string array containing the names of all the roles that the specified user is in for the configured applicationName.
|
||||
/// </returns>
|
||||
public override string[] GetRolesForUser(string username)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of users in the specified role for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role to get the list of users for.</param>
|
||||
/// <returns>
|
||||
/// A string array containing the names of all the users who are members of the specified role for the configured applicationName.
|
||||
/// </returns>
|
||||
public override string[] GetUsersInRole(string roleName)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the specified user is in the specified role for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="username">The user name to search for.</param>
|
||||
/// <param name="roleName">The role to search in.</param>
|
||||
/// <returns>
|
||||
/// true if the specified user is in the specified role for the configured applicationName; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool IsUserInRole(string username, string roleName)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified user names from the specified roles for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="usernames">A string array of user names to be removed from the specified roles.</param>
|
||||
/// <param name="roleNames">A string array of role names to remove the specified user names from.</param>
|
||||
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the specified role name already exists in the role data source for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role to search for in the data source.</param>
|
||||
/// <returns>
|
||||
/// true if the role name already exists in the data source for the configured applicationName; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool RoleExists(string roleName)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -1,43 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
|
||||
namespace umbraco.providers.members
|
||||
{
|
||||
public class Helper
|
||||
{
|
||||
public static bool GuidPseudoTryParse(string guidToTest)
|
||||
{
|
||||
Guid memberUniqueId;
|
||||
try
|
||||
{
|
||||
memberUniqueId = new Guid(guidToTest);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
memberUniqueId = Guid.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Member GetMemberByUsernameOrGuid(string userNameOrGuid)
|
||||
{
|
||||
Member m = null;
|
||||
|
||||
// test if username is a GUID (then it comes from member core login)
|
||||
if (GuidPseudoTryParse(userNameOrGuid))
|
||||
{
|
||||
m = new Member(new Guid(userNameOrGuid));
|
||||
}
|
||||
else
|
||||
{
|
||||
m = Member.GetMemberFromLoginName(userNameOrGuid);
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
using System.Web.Security;
|
||||
using Umbraco.Core;
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using Umbraco.Core.Security;
|
||||
|
||||
namespace umbraco.providers.members
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds some event handling
|
||||
/// </summary>
|
||||
public class MembershipEventHandler : ApplicationEventHandler
|
||||
{
|
||||
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
Member.New += Member_New;
|
||||
}
|
||||
|
||||
void Member_New(Member sender, NewEventArgs e)
|
||||
{
|
||||
//This is a bit of a hack to ensure that the member is approved when created since many people will be using
|
||||
// this old api to create members on the front-end and they need to be approved - which is based on whether or not
|
||||
// the Umbraco membership provider is configured.
|
||||
var provider = MembershipProviderExtensions.GetMembersMembershipProvider() as UmbracoMembershipProvider;
|
||||
if (provider != null)
|
||||
{
|
||||
var approvedField = provider.ApprovedPropertyTypeAlias;
|
||||
var property = sender.getProperty(approvedField);
|
||||
if (property != null)
|
||||
{
|
||||
property.Value = 1;
|
||||
sender.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,187 +0,0 @@
|
||||
#region namespace
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web.Security;
|
||||
using System.Configuration;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Web.Util;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration.Provider;
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using System.Collections;
|
||||
using System.Web.Profile;
|
||||
#endregion
|
||||
|
||||
namespace umbraco.providers.members
|
||||
{
|
||||
public class UmbracoProfileProvider : ProfileProvider
|
||||
{
|
||||
|
||||
private string _applicationName = "";
|
||||
|
||||
public override string ApplicationName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _applicationName;
|
||||
}
|
||||
set
|
||||
{
|
||||
_applicationName = value;
|
||||
}
|
||||
}
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Profile Provider for umbraco member profile data";
|
||||
}
|
||||
}
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Name;
|
||||
}
|
||||
}
|
||||
public override void Initialize(string name, NameValueCollection config)
|
||||
{
|
||||
|
||||
if (config == null)
|
||||
throw new ArgumentNullException("Null configuration parameters");
|
||||
|
||||
if (String.IsNullOrEmpty(name))
|
||||
name = "UmbracoProfileProvider";
|
||||
|
||||
base.Initialize(name, config);
|
||||
|
||||
_applicationName = config["applicationName"];
|
||||
if (String.IsNullOrEmpty(_applicationName))
|
||||
_applicationName = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;
|
||||
config.Remove("applicationName");
|
||||
|
||||
// if the config element contains unused parameters we should throw an exception
|
||||
if (config.Count > 0)
|
||||
{
|
||||
var attrib = config.GetKey(0);
|
||||
if (string.IsNullOrEmpty(attrib) == false)
|
||||
{
|
||||
throw new ProviderException(String.Format("Unrecognized attribute: {0}", attrib));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override int DeleteProfiles(string[] usernames)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override int DeleteProfiles(ProfileInfoCollection profiles)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override ProfileInfoCollection FindInactiveProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override ProfileInfoCollection FindProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override ProfileInfoCollection GetAllInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
public override int GetNumberOfInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns the collection of settings property values for the current umbraco member.
|
||||
/// </summary>
|
||||
/// <param name="context">A <see cref="T:System.Configuration.SettingsContext"/> describing the current application use.</param>
|
||||
/// <param name="collection">A <see cref="T:System.Configuration.SettingsPropertyCollection"/> containing the settings property group whose values are to be retrieved.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="T:System.Configuration.SettingsPropertyValueCollection"/> containing the values for the specified settings property group.
|
||||
/// </returns>
|
||||
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
|
||||
{
|
||||
var settings = new SettingsPropertyValueCollection();
|
||||
|
||||
if (collection.Count == 0)
|
||||
return settings;
|
||||
|
||||
foreach (SettingsProperty property in collection)
|
||||
{
|
||||
var pv = new SettingsPropertyValue(property);
|
||||
settings.Add(pv);
|
||||
}
|
||||
|
||||
// get the current user
|
||||
var username = (string)context["UserName"];
|
||||
var m = Member.GetMemberFromLoginName(username);
|
||||
if (m == null)
|
||||
throw new ProviderException(String.Format("No member with username '{0}' exists", username));
|
||||
|
||||
foreach (SettingsPropertyValue spv in settings)
|
||||
{
|
||||
if (m.getProperty(spv.Name) != null)
|
||||
{
|
||||
spv.Deserialized = true;
|
||||
spv.PropertyValue = m.getProperty(spv.Name).Value;
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the values of the specified group of property settings for the current umbraco member.
|
||||
/// </summary>
|
||||
/// <param name="context">A <see cref="T:System.Configuration.SettingsContext"/> describing the current application usage.</param>
|
||||
/// <param name="collection">A <see cref="T:System.Configuration.SettingsPropertyValueCollection"/> representing the group of property settings to set.</param>
|
||||
public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
|
||||
{
|
||||
|
||||
var username = (string)context["UserName"];
|
||||
var authenticated = (bool)context["IsAuthenticated"];
|
||||
|
||||
if (string.IsNullOrEmpty(username) || collection.Count == 0)
|
||||
return;
|
||||
|
||||
var m = Member.GetMemberFromLoginName(username);
|
||||
if (m == null)
|
||||
throw new ProviderException(String.Format("No member with username '{0}' exists", username));
|
||||
|
||||
|
||||
foreach (SettingsPropertyValue spv in collection)
|
||||
{
|
||||
if (authenticated == false && (bool)spv.Property.Attributes["AllowAnonymous"] == false)
|
||||
continue;
|
||||
|
||||
if (m.getProperty(spv.Name) != null)
|
||||
m.getProperty(spv.Name).Value = spv.PropertyValue;
|
||||
}
|
||||
m.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
#region namespace
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web.Security;
|
||||
using System.Configuration;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Web.Util;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration.Provider;
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using System.Collections;
|
||||
#endregion
|
||||
|
||||
namespace umbraco.providers.members
|
||||
{
|
||||
/// <summary>
|
||||
/// A role provider for members
|
||||
/// </summary>
|
||||
[Obsolete("This has been superceded by Umbraco.Web.Security.Providers.MembersRoleProvider")]
|
||||
public class UmbracoRoleProvider : RoleProvider
|
||||
{
|
||||
|
||||
#region
|
||||
private string _applicationName = Member.UmbracoRoleProviderName;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the application to store and retrieve role information for.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
/// <returns>The name of the application to store and retrieve role information for.</returns>
|
||||
public override string ApplicationName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _applicationName;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
throw new ProviderException("ApplicationName cannot be empty.");
|
||||
|
||||
if (value.Length > 0x100)
|
||||
throw new ProviderException("Provider application name too long.");
|
||||
|
||||
_applicationName = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Initialization Method
|
||||
/// <summary>
|
||||
/// Initializes the provider.
|
||||
/// </summary>
|
||||
/// <param name="name">The friendly name of the provider.</param>
|
||||
/// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param>
|
||||
/// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception>
|
||||
/// <exception cref="T:System.InvalidOperationException">An attempt is made to call
|
||||
/// <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider
|
||||
/// after the provider has already been initialized.</exception>
|
||||
/// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception>
|
||||
public override void Initialize(string name, NameValueCollection config)
|
||||
{
|
||||
// Initialize values from web.config
|
||||
if (config == null) throw new ArgumentNullException("config");
|
||||
|
||||
if (name == null || name.Length == 0) name = "UmbracoMemberRoleProvider";
|
||||
|
||||
if (String.IsNullOrEmpty(config["description"]))
|
||||
{
|
||||
config.Remove("description");
|
||||
config.Add("description", "Umbraco Member Role provider");
|
||||
}
|
||||
|
||||
// Initialize the abstract base class.
|
||||
base.Initialize(name, config);
|
||||
|
||||
this._applicationName = config["applicationName"];
|
||||
if (string.IsNullOrEmpty(this._applicationName))
|
||||
this._applicationName = SecUtility.GetDefaultAppName();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Adds the specified user names to the specified roles for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="usernames">A string array of user names to be added to the specified roles.</param>
|
||||
/// <param name="roleNames">A string array of the role names to add the specified user names to.</param>
|
||||
public override void AddUsersToRoles(string[] usernames, string[] roleNames)
|
||||
{
|
||||
ArrayList roles = new ArrayList();
|
||||
foreach (string role in roleNames)
|
||||
try
|
||||
{
|
||||
roles.Add(MemberGroup.GetByName(role).Id);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new ProviderException(String.Format("No role with name '{0}' exists", role));
|
||||
}
|
||||
foreach (string username in usernames)
|
||||
{
|
||||
Member m = Member.GetMemberFromLoginName(username);
|
||||
foreach (int roleId in roles)
|
||||
m.AddGroup(roleId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new role to the data source for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role to create.</param>
|
||||
public override void CreateRole(string roleName)
|
||||
{
|
||||
MemberGroup.MakeNew(roleName, User.GetUser(0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a role from the data source for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role to delete.</param>
|
||||
/// <param name="throwOnPopulatedRole">If true, throw an exception if roleName has one or more members and do not delete roleName.</param>
|
||||
/// <returns>
|
||||
/// true if the role was successfully deleted; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
|
||||
{
|
||||
MemberGroup group = MemberGroup.GetByName(roleName);
|
||||
if (group == null)
|
||||
throw new ProviderException(String.Format("No role with name '{0}' exists", roleName));
|
||||
else if (throwOnPopulatedRole && group.GetMembersAsIds().Length > 0)
|
||||
throw new ProviderException(String.Format("Can't delete role '{0}', there are members assigned to the role", roleName));
|
||||
else
|
||||
{
|
||||
foreach (Member m in group.GetMembers())
|
||||
m.RemoveGroup(group.Id);
|
||||
group.delete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an array of user names in a role where the user name contains the specified user name to match.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The role to search in.</param>
|
||||
/// <param name="usernameToMatch">The user name to search for.</param>
|
||||
/// <returns>
|
||||
/// A string array containing the names of all the users where the user name matches usernameToMatch and the user is a member of the specified role.
|
||||
/// </returns>
|
||||
public override string[] FindUsersInRole(string roleName, string usernameToMatch)
|
||||
{
|
||||
ArrayList members = new ArrayList();
|
||||
MemberGroup group = MemberGroup.GetByName(roleName);
|
||||
if (group == null)
|
||||
throw new ProviderException(String.Format("No role with name '{0}' exists", roleName));
|
||||
else
|
||||
{
|
||||
foreach (Member m in group.GetMembers(usernameToMatch))
|
||||
members.Add(m.LoginName);
|
||||
return (string[])members.ToArray(typeof(string));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all the roles for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A string array containing the names of all the roles stored in the data source for the configured applicationName.
|
||||
/// </returns>
|
||||
public override string[] GetAllRoles()
|
||||
{
|
||||
ArrayList roles = new ArrayList();
|
||||
foreach (MemberGroup mg in MemberGroup.GetAll)
|
||||
roles.Add(mg.Text);
|
||||
return (string[])roles.ToArray(typeof(string));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of the roles that a specified user is in for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="username">The user to return a list of roles for.</param>
|
||||
/// <returns>
|
||||
/// A string array containing the names of all the roles that the specified user is in for the configured applicationName.
|
||||
/// </returns>
|
||||
public override string[] GetRolesForUser(string username)
|
||||
{
|
||||
ArrayList roles = new ArrayList();
|
||||
Member m = Member.GetMemberFromLoginName(username);
|
||||
if (m != null)
|
||||
{
|
||||
IDictionaryEnumerator ide = m.Groups.GetEnumerator();
|
||||
while (ide.MoveNext())
|
||||
roles.Add(((MemberGroup)ide.Value).Text);
|
||||
return (string[])roles.ToArray(typeof(string));
|
||||
}
|
||||
else
|
||||
throw new ProviderException(String.Format("No member with username '{0}' exists", username));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of users in the specified role for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role to get the list of users for.</param>
|
||||
/// <returns>
|
||||
/// A string array containing the names of all the users who are members of the specified role for the configured applicationName.
|
||||
/// </returns>
|
||||
public override string[] GetUsersInRole(string roleName)
|
||||
{
|
||||
ArrayList members = new ArrayList();
|
||||
MemberGroup group = MemberGroup.GetByName(roleName);
|
||||
if (group == null)
|
||||
throw new ProviderException(String.Format("No role with name '{0}' exists", roleName));
|
||||
else
|
||||
{
|
||||
foreach (Member m in group.GetMembers())
|
||||
members.Add(m.LoginName);
|
||||
return (string[])members.ToArray(typeof(string));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the specified user is in the specified role for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="username">The user name to search for.</param>
|
||||
/// <param name="roleName">The role to search in.</param>
|
||||
/// <returns>
|
||||
/// true if the specified user is in the specified role for the configured applicationName; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool IsUserInRole(string username, string roleName)
|
||||
{
|
||||
Member m = Member.GetMemberFromLoginName(username);
|
||||
if (m == null)
|
||||
throw new ProviderException(String.Format("No user with name '{0}' exists", username));
|
||||
else
|
||||
{
|
||||
MemberGroup mg = MemberGroup.GetByName(roleName);
|
||||
if (mg == null)
|
||||
throw new ProviderException(String.Format("No Membergroup with name '{0}' exists", roleName));
|
||||
else
|
||||
return mg.HasMember(m.Id);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified user names from the specified roles for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="usernames">A string array of user names to be removed from the specified roles.</param>
|
||||
/// <param name="roleNames">A string array of role names to remove the specified user names from.</param>
|
||||
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
|
||||
{
|
||||
ArrayList roles = new ArrayList();
|
||||
foreach (string role in roleNames)
|
||||
try
|
||||
{
|
||||
roles.Add(MemberGroup.GetByName(role).Id);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new ProviderException(String.Format("No role with name '{0}' exists", role));
|
||||
}
|
||||
foreach (string username in usernames)
|
||||
{
|
||||
Member m = Member.GetMemberFromLoginName(username);
|
||||
foreach (int roleId in roles)
|
||||
m.RemoveGroup(roleId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the specified role name already exists in the role data source for the configured applicationName.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role to search for in the data source.</param>
|
||||
/// <returns>
|
||||
/// true if the role name already exists in the data source for the configured applicationName; otherwise, false.
|
||||
/// </returns>
|
||||
public override bool RoleExists(string roleName)
|
||||
{
|
||||
MemberGroup mg = MemberGroup.GetByName(roleName);
|
||||
return mg != null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{D7636876-0756-43CB-A192-138C6F0D5E42}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>umbraco.providers</RootNamespace>
|
||||
<AssemblyName>umbraco.providers</AssemblyName>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\umbraco.providers.xml</DocumentationFile>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.ApplicationServices" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SolutionInfo.cs">
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="members\Helper.cs" />
|
||||
<Compile Include="members\MembershipEventHandler.cs" />
|
||||
<Compile Include="members\UmbracoMembershipProvider.cs" />
|
||||
<Compile Include="members\UmbracoProfileProvider.cs" />
|
||||
<Compile Include="members\UmbracoRoleProvider.cs" />
|
||||
<Compile Include="SecUtility.cs" />
|
||||
<Compile Include="UsersMembershipProvider.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UsersMembershipUser.cs" />
|
||||
<Compile Include="UsersRoleProvider.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\umbraco.businesslogic\umbraco.businesslogic.csproj">
|
||||
<Project>{E469A9CE-1BEC-423F-AC44-713CD72457EA}</Project>
|
||||
<Name>umbraco.businesslogic</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\umbraco.cms\umbraco.cms.csproj">
|
||||
<Project>{ccd75ec3-63db-4184-b49d-51c1dd337230}</Project>
|
||||
<Name>umbraco.cms</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj">
|
||||
<Project>{31785bc3-256c-4613-b2f5-a1b0bdded8c1}</Project>
|
||||
<Name>Umbraco.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\umbraco.datalayer\umbraco.datalayer.csproj">
|
||||
<Project>{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}</Project>
|
||||
<Name>umbraco.datalayer</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\umbraco.interfaces\umbraco.interfaces.csproj">
|
||||
<Project>{511F6D8D-7717-440A-9A57-A507E9A8B27F}</Project>
|
||||
<Name>umbraco.interfaces</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -65,8 +65,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.cms", "umbraco.cms\
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.interfaces", "umbraco.interfaces\umbraco.interfaces.csproj", "{511F6D8D-7717-440A-9A57-A507E9A8B27F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.providers", "umbraco.providers\umbraco.providers.csproj", "{D7636876-0756-43CB-A192-138C6F0D5E42}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.datalayer", "umbraco.datalayer\umbraco.datalayer.csproj", "{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.controls", "umbraco.controls\umbraco.controls.csproj", "{6EDD2061-82F2-461B-BB6E-879245A832DE}"
|
||||
@@ -128,10 +126,6 @@ Global
|
||||
{511F6D8D-7717-440A-9A57-A507E9A8B27F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{511F6D8D-7717-440A-9A57-A507E9A8B27F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{511F6D8D-7717-440A-9A57-A507E9A8B27F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D7636876-0756-43CB-A192-138C6F0D5E42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D7636876-0756-43CB-A192-138C6F0D5E42}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D7636876-0756-43CB-A192-138C6F0D5E42}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D7636876-0756-43CB-A192-138C6F0D5E42}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
||||
Reference in New Issue
Block a user