public bool AddUser(string userName, string friendlyName, SecureString password, DateTime? expireDate, string userType) { Exception _e = null; try { using (var command = DatabaseProvider.DbProviderFactory.CreateCommand()) { var resolvedName = UserNameResolver.ToDb(userName, userType); InitializeGenericAddUserCommandExt(command, resolvedName.Item1, resolvedName.Item2, friendlyName, GetHashedPassword(password), expireDate, resolvedName.Item3); return (DatabaseProvider.ExecuteNonQuery(command) > 0); } } catch (Exception e) { //might fail for older schema databases, we fall through for backward compatibility _e = e; } try { using (var command = DatabaseProvider.DbProviderFactory.CreateCommand()) { InitializeGenericAddUserCommand(command, userName, friendlyName, GetHashedPassword(password), expireDate, string.IsNullOrEmpty(userType) ? UserType.Classic : userType); return (DatabaseProvider.ExecuteNonQuery(command) > 0); } } catch (Exception e) { //might fail for older schema databases, we fall through for backward compatibility _e = e; } if (string.IsNullOrEmpty(userType) || userType == UserType.Classic) { return base.AddUser(userName, friendlyName, password, expireDate, false); } else if (userType == UserType.SmartCard) { return base.AddUser(userName, friendlyName, password, expireDate, true); } else { throw _e; } }
//all interface methods implementations that receive a userName should call this function public virtual string FromInputUserName(string userName) { return(UserNameResolver.ToDb(userName, string.Empty).Item1); }