Local user name is prohibited

Currently, if I try to add the local user "jim, bob" to Windows 7, the following dialog box is expected to display all invalid characters for the username. Is there a quick .net method for a call that returns the same characters? For instance.

Path.GetInvalidPathChars(); 

returns all invalid path characters. Is there a similar method for usernames?

enter image description here

+6
source share
2 answers

Path.GetInvalidFileNameChars () -?

Username Policies from http://technet.microsoft.com/en-us/library/cc722458.aspx

The key policy to establish is the naming scheme for accounts. On Windows NT, user names must comply with the following rules:

Local usernames must be unique on the workstation.

Global usernames must be unique throughout the domain.

Usernames must be 20 characters or less.

Usernames cannot contain specific characters. Unacceptable symbols:

"/ \ [] :; | =, + *? <>

Usernames can contain all other special characters, including spaces, periods, dashes, and underscores. But usually it is not recommended to use spaces in account names. On some systems other than Windows NT, such as UNIX, spaces are not allowed in user names, and it may be difficult for the user to access these systems.

+1
source

What you need:

Path.GetInvalidFileNameChars()

Take a look at this in more detail: http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidfilenamechars.aspx

0
source

Source: https://habr.com/ru/post/905124/


All Articles