Skip to content

Commit 12752fb

Browse files
committed
#441 : Fixed validation for user names.
1 parent f5f66db commit 12752fb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Cognifide.PowerShell/Commandlets/Security/AccountIdentity.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public AccountIdentity(string name)
1919
domain = StringUtil.GetPrefix(name, '\\');
2020
account = StringUtil.GetPostfix(name, '\\');
2121
}
22-
23-
if (!Regex.IsMatch(account, "^\\w[\\w\\s]*$", RegexOptions.Compiled))
22+
23+
if (!Regex.IsMatch(account, @"^\w[\w\s.\\_-]*$", RegexOptions.Compiled))
2424
{
25-
throw new ArgumentException("The name \"{0}\" contains illegal characters.\n\nThe name can only contain the following characters: A-Z, a-z, 0-9 and space.", name);
25+
throw new ArgumentException(String.Format("The name '{0}' contains illegal characters.\n\nThe name can only contain the following characters: a-z, 0-9, periods, dashes, underscores, and spaces.", account), account);
2626
}
2727

2828
Domain = domain;

0 commit comments

Comments
 (0)