Source code of Windows XP (NT5)
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.

188 lines
4.9 KiB

  1. #include <windows.h>
  2. #include <windowsx.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdarg.h>
  6. #include <stdlib.h>
  7. #include "dapi.h"
  8. DWORD SyntaxData[] =
  9. {
  10. 0x80000002, //
  11. 0x0000001c, // emit the proxy prefix
  12. 0x00000002, //
  13. 0x6701001E, // emit the fax address
  14. 0x80000002, //
  15. 0x00000024, // emit the proxy suffix
  16. 0x00000000, // HALT
  17. '[XAF', //
  18. '\0\0\0\0', //
  19. '\0]\0\0' //
  20. };
  21. DWORD AddressData[] =
  22. {
  23. 0x00000001, 0x00000006, 0x00000000, 0x00000000,
  24. 0x00000000, 0x00000000, 0x00000008, 0x00000000,
  25. 0x00000000, 0x00000000, 0x000000E0, 0x00000007,
  26. 0x0000003C, 0x0000000C, 0x0000000C, 0x00000000,
  27. 0x00000000, 0x00000000, 0x00000000, 0x000000F2,
  28. 0x00000047, 0x000000A0, 0x0000000C, 0x0000000C,
  29. 0x00000001, 0x00000006, 0x3001001E, 0x00000100,
  30. 0x00000112, 0x00000007, 0x0000003C, 0x0000001E,
  31. 0x0000000C, 0x00000000, 0x00000000, 0x00000000,
  32. 0x00000000, 0x00000116, 0x00000047, 0x000000A0,
  33. 0x0000001E, 0x0000000C, 0x00000001, 0x00000002,
  34. 0x6701001E, 0x00000050, 0x00000134, 0x0000000C,
  35. 0x0000003C, 0x00000064, 0x0000000C, 0x00000000,
  36. 0x00000000, 0x00000000, 0x00000000, 0x0000013A,
  37. 0x00650047, 0x0065006E, 0x00610072, 0x0020006C,
  38. 0x00260000, 0x00690044, 0x00700073, 0x0061006C,
  39. 0x00200079, 0x0061004E, 0x0065006D, 0x0020003A,
  40. 0x002A0000, 0x00260000, 0x00610046, 0x00200078,
  41. 0x00640041, 0x00720064, 0x00730065, 0x003A0073,
  42. 0x00000020, 0x0020002A, 0x00000000
  43. };
  44. VOID
  45. AddValue(
  46. PATT_VALUE Value,
  47. DAPI_DATA_TYPE DataType,
  48. LPBYTE DataValue,
  49. DWORD DataSize
  50. )
  51. {
  52. Value->DapiType = DataType;
  53. Value->Value.lpBinary = (LPBYTE) DataValue;
  54. Value->size = DataSize;
  55. Value->pNextValue = NULL;
  56. }
  57. VOID
  58. AddStringValue(
  59. PATT_VALUE Value,
  60. LPSTR String
  61. )
  62. {
  63. AddValue(
  64. Value,
  65. DAPI_STRING8,
  66. String,
  67. strlen(String)
  68. );
  69. }
  70. VOID
  71. AddBinaryValue(
  72. PATT_VALUE Value,
  73. LPBYTE BinaryData,
  74. DWORD BinaryDataSize
  75. )
  76. {
  77. AddValue(
  78. Value,
  79. DAPI_BINARY,
  80. BinaryData,
  81. BinaryDataSize
  82. );
  83. }
  84. int _cdecl
  85. main(
  86. int argc,
  87. char *argv[]
  88. )
  89. {
  90. DAPI_PARMS dp;
  91. DAPI_HANDLE dh;
  92. PDAPI_EVENT de;
  93. DAPI_ENTRY enA;
  94. ATT_VALUE vlA[32];
  95. DAPI_ENTRY enV;
  96. ATT_VALUE vlV[32];
  97. CHAR BasePoint[128];
  98. sprintf( BasePoint, "/O=%s/OU=%s/cn=Configuration/cn=Addressing/cn=Address-Templates/cn=409", argv[1], argv[2] );
  99. dp.dwDAPISignature = DAPI_SIGNATURE;
  100. dp.dwFlags = 0;
  101. dp.pszDSAName = NULL;
  102. dp.pszBasePoint = BasePoint;
  103. dp.pszContainer = NULL;
  104. dp.pszNTDomain = NULL;
  105. dp.pszCreateTemplate = NULL;
  106. dp.pAttributes = NULL;
  107. de = DAPIStart( &dh, &dp );
  108. if (de) {
  109. printf( "could not start DAPI\n" );
  110. return -1;
  111. }
  112. enA.unAttributes = 3;
  113. enA.ulEvalTag = VALUE_ARRAY;
  114. enA.rgEntryValues = vlA;
  115. AddStringValue( &vlA[0], "Obj-Class" );
  116. AddStringValue( &vlA[1], "Mode" );
  117. AddStringValue( &vlA[2], "Common-Name" );
  118. enV.unAttributes = 3;
  119. enV.ulEvalTag = VALUE_ARRAY;
  120. enV.rgEntryValues = vlV;
  121. AddStringValue( &vlV[0], "Address-Template" );
  122. AddStringValue( &vlV[1], "Update" );
  123. AddStringValue( &vlV[2], "FAX" );
  124. de = DAPIWrite( dh, DAPI_WRITE_UPDATE, &enA, &enV, NULL, NULL, NULL );
  125. if (de) {
  126. printf( "could not write to DAPI #1\n" );
  127. return -1;
  128. }
  129. enA.unAttributes = 7;
  130. enA.ulEvalTag = VALUE_ARRAY;
  131. enA.rgEntryValues = vlA;
  132. AddStringValue( &vlA[0], "Obj-Class" );
  133. AddStringValue( &vlA[1], "Mode" );
  134. AddStringValue( &vlA[2], "Admin-Display-Name" );
  135. AddStringValue( &vlA[3], "Common-Name" );
  136. AddStringValue( &vlA[4], "Address-Type" );
  137. AddStringValue( &vlA[5], "Address-Syntax" );
  138. AddStringValue( &vlA[6], "Address-Entry-Display-Table" );
  139. enV.unAttributes = 7;
  140. enV.ulEvalTag = VALUE_ARRAY;
  141. enV.rgEntryValues = vlV;
  142. AddStringValue( &vlV[0], "Address-Template" );
  143. AddStringValue( &vlV[1], "Update" );
  144. AddStringValue( &vlV[2], "Fax Address" );
  145. AddStringValue( &vlV[3], "FAX" );
  146. AddStringValue( &vlV[4], "FAX" );
  147. AddBinaryValue( &vlV[5], (LPBYTE) SyntaxData, sizeof(SyntaxData) );
  148. AddBinaryValue( &vlV[6], (LPBYTE) AddressData, sizeof(AddressData) );
  149. de = DAPIWrite( dh, DAPI_WRITE_UPDATE, &enA, &enV, NULL, NULL, NULL );
  150. if (de) {
  151. printf( "could not write to DAPI #2\n" );
  152. return -1;
  153. }
  154. DAPIEnd( dh );
  155. return 0;
  156. }