dsparse.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * WinPR: Windows Portable Runtime
  3. * Active Directory Domain Services Parsing Functions
  4. *
  5. * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. #ifdef HAVE_CONFIG_H
  20. #include "config.h"
  21. #endif
  22. #include <winpr/dsparse.h>
  23. /**
  24. * dsparse.dll:
  25. *
  26. * DsCrackSpnA
  27. * DsCrackSpnW
  28. * DsCrackUnquotedMangledRdnA
  29. * DsCrackUnquotedMangledRdnW
  30. * DsGetRdnW
  31. * DsIsMangledDnA
  32. * DsIsMangledDnW
  33. * DsIsMangledRdnValueA
  34. * DsIsMangledRdnValueW
  35. * DsMakeSpnA
  36. * DsMakeSpnW
  37. * DsQuoteRdnValueA
  38. * DsQuoteRdnValueW
  39. * DsUnquoteRdnValueA
  40. * DsUnquoteRdnValueW
  41. */
  42. #if !defined(_WIN32) || defined(_UWP)
  43. DWORD DsCrackSpnW(LPCWSTR pszSpn, DWORD* pcServiceClass, LPWSTR ServiceClass, DWORD* pcServiceName,
  44. LPWSTR ServiceName, DWORD* pcInstanceName, LPWSTR InstanceName,
  45. USHORT* pInstancePort)
  46. {
  47. return 0;
  48. }
  49. DWORD DsCrackSpnA(LPCSTR pszSpn, LPDWORD pcServiceClass, LPSTR ServiceClass, LPDWORD pcServiceName,
  50. LPSTR ServiceName, LPDWORD pcInstanceName, LPSTR InstanceName,
  51. USHORT* pInstancePort)
  52. {
  53. return 0;
  54. }
  55. DWORD DsMakeSpnW(LPCWSTR ServiceClass, LPCWSTR ServiceName, LPCWSTR InstanceName,
  56. USHORT InstancePort, LPCWSTR Referrer, DWORD* pcSpnLength, LPWSTR pszSpn)
  57. {
  58. return 0;
  59. }
  60. DWORD DsMakeSpnA(LPCSTR ServiceClass, LPCSTR ServiceName, LPCSTR InstanceName, USHORT InstancePort,
  61. LPCSTR Referrer, DWORD* pcSpnLength, LPSTR pszSpn)
  62. {
  63. DWORD SpnLength;
  64. DWORD ServiceClassLength;
  65. DWORD ServiceNameLength;
  66. if ((*pcSpnLength != 0) && (pszSpn == NULL))
  67. return ERROR_INVALID_PARAMETER;
  68. ServiceClassLength = (DWORD)strlen(ServiceClass);
  69. ServiceNameLength = (DWORD)strlen(ServiceName);
  70. SpnLength = ServiceClassLength + 1 + ServiceNameLength + 1;
  71. if ((*pcSpnLength == 0) || (*pcSpnLength < SpnLength))
  72. {
  73. *pcSpnLength = SpnLength;
  74. return ERROR_BUFFER_OVERFLOW;
  75. }
  76. sprintf_s(pszSpn, *pcSpnLength, "%s/%s", ServiceClass, ServiceName);
  77. return ERROR_SUCCESS;
  78. }
  79. #endif