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.

101 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. SessMtch.c
  5. Abstract:
  6. This file contains RxpSessionMatches().
  7. Author:
  8. John Rogers (JohnRo) 17-Oct-1991
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Requires ANSI C extensions: slash-slash comments, long external names.
  12. Revision History:
  13. 17-Oct-1991 JohnRo
  14. Created.
  15. 18-Oct-1991 JohnRo
  16. Fixed bug: sesiX_cname is not a UNC name.
  17. 25-Oct-1991 JohnRo
  18. Fixed bug: allow UncClientName and UserName to point to null char.
  19. --*/
  20. // These must be included first:
  21. #include <windef.h> // IN, DWORD, etc.
  22. #include <lmcons.h> // NET_API_STATUS, etc.
  23. #include <lmshare.h> // Required by rxsess.h.
  24. // These may be included in any order:
  25. #include <netdebug.h> // NetpAssert().
  26. #include <rxsess.h> // My prototype.
  27. #include <tstring.h> // STRICMP().
  28. BOOL
  29. RxpSessionMatches (
  30. IN LPSESSION_SUPERSET_INFO Candidate,
  31. IN LPTSTR UncClientName OPTIONAL,
  32. IN LPTSTR UserName OPTIONAL
  33. )
  34. /*++
  35. Routine Description:
  36. RxpSessionMatches is used to determine whether or not a given session
  37. structure (part of an array, probably) matches the given client name
  38. and user name.
  39. Arguments:
  40. Candidate - possible match in the form of a superset info structure.
  41. UncClientName - an optional UNC computer name.
  42. UserName - an optional user name.
  43. Return Value:
  44. BOOL - TRUE if structure matches client name and user name.
  45. --*/
  46. {
  47. NetpAssert(Candidate != NULL);
  48. NetpAssert(SESSION_SUPERSET_LEVEL == 2); // assumed by code below.
  49. if ( (UncClientName != NULL) && (*UncClientName != '\0') ) {
  50. NetpAssert( Candidate->sesi2_cname != NULL );
  51. NetpAssert( UncClientName[0] == '\\' );
  52. NetpAssert( UncClientName[1] == '\\' );
  53. if (STRICMP( &UncClientName[2], Candidate->sesi2_cname) != 0) {
  54. return (FALSE); // no match.
  55. }
  56. }
  57. if ( (UserName != NULL) && (*UserName != '\0') ) {
  58. NetpAssert(Candidate->sesi2_username != NULL);
  59. if (STRICMP(UserName, Candidate->sesi2_username) != 0) {
  60. return (FALSE); // no match.
  61. }
  62. }
  63. return (TRUE); // matches.
  64. } // RxpSessionMatches