local user name disallowed chars
-
14-04-2021 - |
سؤال
currently if I try to add local user "jim,bob" to a Windows 7 system, as expected, the following error dialog is shown displaying all the illegal chars for a user name. Is there a quick .net method to call which returns the same chars? E.g.
Path.GetInvalidPathChars();
returns all the invalid path chars. Is there a similar method out there for user names?
المحلول
Path.GetInvalidFileNameChars() - ?
User Name Policies from http://technet.microsoft.com/en-us/library/cc722458.aspx
A key policy you'll need to set is the naming scheme for accounts. In Windows NT, user names must follow these rules:
Local user names must be unique on a workstation.
Global user names must be unique throughout a domain.
User names must be no more than 20 characters in length.
User names cannot contain certain characters. Invalid characters include:
" / \ [ ] : ; | = , + * ? < >
User names can contain all other special characters, including spaces, periods, dashes, and underscores. But it's generally not a good idea to use spaces in account names. On some non-Windows NT systems, such as UNIX, spaces aren't valid in user names and the user may have difficulty accessing these systems.
نصائح أخرى
What you need is this:
Path.GetInvalidFileNameChars()
Look at this for more details: http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidfilenamechars.aspx