当前位置: 首页>>代码示例>>C++>>正文


C++ URI::password方法代码示例

本文整理汇总了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;
}
开发者ID:Akagi201,项目名称:crtmpserver,代码行数:31,代码来源:basevariantappprotocolhandler.cpp

示例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] != '(')
//.........这里部分代码省略.........
开发者ID:monnerat,项目名称:undervest,代码行数:101,代码来源:ldap.cpp


注:本文中的URI::password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。