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.

47 lines
1.4 KiB

  1. #include <windows.h>
  2. #include <wincred.h>
  3. #include "io.h"
  4. #include "consmsg.h"
  5. extern WCHAR szUsername[];
  6. /*
  7. Accept as input a username via a pointer. Return a pointer (to the global buffer)
  8. which contains the username string unmodified if it is not a marshalled cert name,
  9. or the certificate display name if it is a certificate.
  10. */
  11. WCHAR *
  12. UnMarshallUserName
  13. (WCHAR *pszMarshalled)
  14. {
  15. if (CredIsMarshaledCredential(pszMarshalled))
  16. {
  17. CRED_MARSHAL_TYPE ct;
  18. PVOID pumc = NULL;
  19. if (CredUnmarshalCredential(pszMarshalled,
  20. &ct,
  21. &pumc))
  22. {
  23. if (ct == CertCredential)
  24. {
  25. // for now, we're not going to use the actual unmarshalled name, just a constant string
  26. CredFree(pumc);
  27. wcsncpy(szUsername, ComposeString(MSG_ISCERT),CRED_MAX_USERNAME_LENGTH);
  28. return szUsername;
  29. }
  30. else
  31. {
  32. // This marshalled type should never be persisted in the store. Pretend it's not really marshalled.
  33. return pszMarshalled;
  34. }
  35. }
  36. else
  37. {
  38. // use missing certificate string
  39. wcsncpy(szUsername, ComposeString(MSG_NOCERT),CRED_MAX_USERNAME_LENGTH);
  40. return szUsername;
  41. }
  42. }
  43. return pszMarshalled;
  44. }