diff --git a/src/umbraco.businesslogic/User.cs b/src/umbraco.businesslogic/User.cs index 7a7574e230..5e7335d03a 100644 --- a/src/umbraco.businesslogic/User.cs +++ b/src/umbraco.businesslogic/User.cs @@ -399,20 +399,38 @@ namespace umbraco.BusinessLogic } - /// + /// /// Gets all users by email. /// /// The email. /// - public static User[] getAllByEmail(string email) + public static User[] getAllByEmail(string email) + { + return getAllByEmail(email, false); + } + + /// + /// Gets all users by email. + /// + /// The email. + /// match exact email address or partial email address. + /// + public static User[] getAllByEmail(string email, bool useExactMatch) { List retVal = new List(); System.Collections.ArrayList tmpContainer = new System.Collections.ArrayList(); + + IRecordsReader dr; - IRecordsReader dr; - dr = SqlHelper.ExecuteReader( - "Select id from umbracoUser where userEmail LIKE @email", SqlHelper.CreateParameter("@email", String.Format("%{0}%", email))); - + if (useExactMatch == true) + { + dr = SqlHelper.ExecuteReader("Select id from umbracoUser where userEmail = @email", SqlHelper.CreateParameter("@email", email)); + } + else + { + dr = SqlHelper.ExecuteReader("Select id from umbracoUser where userEmail LIKE {0} @email", SqlHelper.CreateParameter("@email", String.Format("%{0}%", email))); + } + while (dr.Read()) { retVal.Add(BusinessLogic.User.GetUser(dr.GetInt("id"))); @@ -432,6 +450,17 @@ namespace umbraco.BusinessLogic return GetAllByLoginName(login, false).ToArray(); } + /// + /// Gets all users by login name. + /// + /// The login. + /// whether to use a partial match + /// + public static User[] getAllByLoginName(string login, bool partialMatch) + { + return GetAllByLoginName(login, partialMatch).ToArray(); + } + public static IEnumerable GetAllByLoginName(string login, bool partialMatch) {