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.

93 lines
2.6 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // ldapdnary.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file declares the class LDAPDictionary.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 02/24/1998 Original version.
  16. // 04/20/1998 Added flags and InjectorProc to the attribute schema.
  17. // 05/01/1998 Changed signature of InjectorProc.
  18. //
  19. ///////////////////////////////////////////////////////////////////////////////
  20. #ifndef _LDAPDNARY_H_
  21. #define _LDAPDNARY_H_
  22. #include <iaspolcy.h>
  23. #include <winldap.h>
  24. //////////
  25. // Prototype for an injector procedure. These are procedures for inserting
  26. // attributes into a request.
  27. //////////
  28. typedef VOID (WINAPI *InjectorProc)(
  29. IAttributesRaw* dst,
  30. PATTRIBUTEPOSITION first,
  31. PATTRIBUTEPOSITION last
  32. );
  33. //////////
  34. // Struct that defines an LDAP/IAS attribute.
  35. //////////
  36. struct LDAPAttribute
  37. {
  38. PCWSTR ldapName; // The LDAP name of the attribute.
  39. DWORD iasID; // The IAS attribute ID.
  40. IASTYPE iasType; // The IAS syntax of the attribute.
  41. DWORD flags; // Flags that should be applied to the attribute.
  42. InjectorProc injector; // Used for adding the attribute to the request.
  43. };
  44. ///////////////////////////////////////////////////////////////////////////////
  45. //
  46. // CLASS
  47. //
  48. // LDAPDictionary
  49. //
  50. // DESCRIPTION
  51. //
  52. // This class uses a sorted array of LDAPAttribute's to convert LDAP
  53. // attribute/value pairs into IASATTRIBUTE structs.
  54. //
  55. ///////////////////////////////////////////////////////////////////////////////
  56. class LDAPDictionary
  57. {
  58. public:
  59. // 'entries' must already be sorted.
  60. LDAPDictionary(
  61. size_t numEntries,
  62. const LDAPAttribute* entries
  63. ) throw ()
  64. : num(numEntries), base(entries)
  65. { }
  66. // Finds the definition for a given attribute. Returns NULL if not found.
  67. const LDAPAttribute* find(PCWSTR key) const throw ()
  68. {
  69. return (const LDAPAttribute*)
  70. bsearch(&key, base, num, sizeof(LDAPAttribute), compare);
  71. }
  72. // Inserts all the attributes from src into dst.
  73. void insert(
  74. IAttributesRaw* dst,
  75. LDAPMessage* src
  76. ) const;
  77. protected:
  78. const size_t num; // Number of attributes in dictionary.
  79. const LDAPAttribute* const base; // Sorted array of attributes.
  80. // Comparison function used for searching the dictionary.
  81. static int __cdecl compare(const void *elem1, const void *elem2);
  82. };
  83. #endif // _LDAPDNARY_H_