CURLOPT_USERNAME.3 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. .\" generated by cd2nroff 0.1 from CURLOPT_USERNAME.md
  2. .TH CURLOPT_USERNAME 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_USERNAME \- username to use in authentication
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERNAME,
  9. char *username);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a char pointer as parameter, which should be pointing to the
  13. null\-terminated username to use for the transfer.
  14. \fICURLOPT_USERNAME(3)\fP sets the username to be used in protocol
  15. authentication. You should not use this option together with the (older)
  16. \fICURLOPT_USERPWD(3)\fP option.
  17. When using Kerberos V5 authentication with a Windows based server, you should
  18. include the domain name in order for the server to successfully obtain a
  19. Kerberos Ticket. If you do not then the initial part of the authentication
  20. handshake may fail.
  21. When using NTLM, the username can be specified simply as the username without
  22. the domain name should the server be part of a single domain and forest.
  23. To include the domain name use either Down\-Level Logon Name or UPN (User
  24. Principal Name) formats. For example, \fBEXAMPLE\user\fP and
  25. \fBuser@example.com\fP respectively.
  26. Some HTTP servers (on Windows) support inclusion of the domain for Basic
  27. authentication as well.
  28. To specify the password and login options, along with the username, use the
  29. \fICURLOPT_PASSWORD(3)\fP and \fICURLOPT_LOGIN_OPTIONS(3)\fP options.
  30. The application does not have to keep the string around after setting this
  31. option.
  32. .SH DEFAULT
  33. blank
  34. .SH PROTOCOLS
  35. This functionality affects all supported protocols
  36. .SH EXAMPLE
  37. .nf
  38. int main(void)
  39. {
  40. CURL *curl = curl_easy_init();
  41. if(curl) {
  42. CURLcode res;
  43. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  44. curl_easy_setopt(curl, CURLOPT_USERNAME, "clark");
  45. res = curl_easy_perform(curl);
  46. curl_easy_cleanup(curl);
  47. }
  48. }
  49. .fi
  50. .SH AVAILABILITY
  51. Added in curl 7.19.1
  52. .SH RETURN VALUE
  53. Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
  54. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  55. .SH SEE ALSO
  56. .BR CURLOPT_HTTPAUTH (3),
  57. .BR CURLOPT_PASSWORD (3),
  58. .BR CURLOPT_PROXYAUTH (3),
  59. .BR CURLOPT_USERPWD (3)