Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. AcctName.c
  5. Abstract:
  6. Contains miscellaneous utility functions used by the Service
  7. Controller:
  8. ScIsValidAccountName
  9. Author:
  10. John Rogers (JohnRo) 14-Apr-1992
  11. Environment:
  12. User Mode -Win32
  13. Revision History:
  14. 14-Apr-1992 JohnRo
  15. Created.
  16. 20-May-1992 JohnRo
  17. Use CONST where possible.
  18. --*/
  19. #include <nt.h>
  20. #include <ntrtl.h>
  21. //#include <nturtl.h>
  22. #include <windef.h>
  23. #include <scdebug.h> // SC_ASSERT().
  24. #include <sclib.h> // My prototype.
  25. #include <stdlib.h> // wcschr().
  26. BOOL
  27. ScIsValidAccountName(
  28. IN LPCWSTR lpAccountName
  29. )
  30. /*++
  31. Routine Description:
  32. This function validates a given service Account name.
  33. Arguments:
  34. lpAccountName - Supplies the Account name to be validated.
  35. Return Value:
  36. TRUE - The name is valid.
  37. FALSE - The name is invalid.
  38. --*/
  39. {
  40. if (lpAccountName == NULL) {
  41. return (FALSE); // Missing name isn't valid.
  42. } else if ( (*lpAccountName) == L'\0' ) {
  43. return (FALSE); // Missing name isn't valid.
  44. }
  45. //
  46. // name is account name ("domain\user" or ".\user" or LocalSystem).
  47. //
  48. if (lpAccountName[0] == L'\\') {
  49. return (FALSE);
  50. }
  51. //
  52. // The account name is canonicalized and validated later.
  53. //
  54. return TRUE;
  55. }