本文整理汇总了C++中URI::password方法的典型用法代码示例。如果您正苦于以下问题:C++ URI::password方法的具体用法?C++ URI::password怎么用?C++ URI::password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URI
的用法示例。
在下文中一共展示了URI::password方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetScaffold
Variant BaseVariantAppProtocolHandler::GetScaffold(string uriString) {
//1. Search in the cache first
if (_urlCache.HasKey(uriString)) {
return _urlCache[uriString];
}
//2. Build it
Variant result;
//3. Split the URL into components
URI uri;
if (!URI::FromString(uriString, true, uri)) {
FATAL("Invalid url: %s", STR(uriString));
return Variant();
}
//6. build the end result
result["username"] = uri.userName();
result["password"] = uri.password();
result["host"] = uri.host();
result["ip"] = uri.ip();
result["port"] = uri.port();
result["document"] = uri.fullDocumentPath();
result["applicationName"] = GetApplication()->GetName();
//7. Save it in the cache
_urlCache[uriString] = result;
//8. Done
return result;
}
示例2: runtime_error
extern "C" void *
openSource(Source * source)
{
URI u;
ldap_handle * h;
int version;
int rc;
int i;
char * s;
int msgid;
std::string locfilter;
struct berval passwd;
struct timeval tv;
if (!source->uri.length())
throw std::runtime_error("LDAP loader requires an LDAP URI");
// Create the handle.
h = new ldap_handle();
h->source = source;
// Extract the binddn:password from the URI and rebuild
// an authentication-less URI.
try {
if (!u.parse(source->uri))
throw std::runtime_error("Cannot parse URI");
if (u.user().empty() && u.password().empty())
h->binddn = u.unescape(u.userinfo());
else {
h->binddn = u.user();
h->password = u.password();
}
u.userinfo("");
// Parse the LDAP URI.
if ((rc = ldap_url_parse(std::string(u).c_str(), &h->uri)) !=
LDAP_SUCCESS)
throw ldap_error(rc);
if (!h->uri->lud_attrs[0])
throw std::runtime_error(
"LDAP url should select at least one attribute");
// Connect to LDAP server.
rc = ldap_initialize(&h->ldap, ((std::string(h->uri->lud_scheme?
h->uri->lud_scheme: "ldap")) + "://" +
(h->uri->lud_host? h->uri->lud_host: "") +
(h->uri->lud_port? ":" +
std::to_string(h->uri->lud_port): "")).c_str());
if (rc != LDAP_SUCCESS)
throw ldap_error(rc);
// Set a very low timeout: connection should be quick.
tv.tv_sec = 5;
tv.tv_usec = 0;
ldap_set_option(h->ldap, LDAP_OPT_NETWORK_TIMEOUT, &tv);
// Bind if needed.
if (ldap_get_option(h->ldap,
LDAP_OPT_PROTOCOL_VERSION, &version) != LDAP_SUCCESS)
version = LDAP_VERSION2; // Bind is mandatory.
rc = LDAP_SUCCESS;
if (!h->binddn.length()) {
if (version >= LDAP_VERSION2) {
// Anonymous bind is mandatory for
// version 2.
rc = ldap_sasl_bind_s(h->ldap, "",
LDAP_SASL_SIMPLE, NULL, NULL, NULL, NULL);
}
}
else {
passwd.bv_val = (char *) h->password.c_str();
passwd.bv_len = h->password.length();
rc = ldap_sasl_bind_s(h->ldap, h->binddn.c_str(),
LDAP_SASL_SIMPLE, &passwd, NULL, NULL, NULL);
}
if (rc != LDAP_SUCCESS)
throw ldap_error(rc);
// Update the given filter to not select entries not
// providing mail address attributes.
locfilter = h->uri->lud_filter;
if (locfilter.length()) {
if (locfilter[0] != '(')
//.........这里部分代码省略.........