Click here to Skip to main content
15,897,187 members
Articles / Programming Languages / C++

.NET Client Classes for openldap/winldap

Rate me:
Please Sign up or sign in to vote.
4.88/5 (17 votes)
11 Mar 2003CPOL5 min read 246.2K   2.3K   62  
An example of using LDAP/OpenLDAP with .Net
/**************************************************************************
   THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
   ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
   PARTICULAR PURPOSE.
   Author: Leon Finker  9/2002
**************************************************************************/
#pragma once

class CIntPtrStringAnsi
{
public:
	CIntPtrStringAnsi(const gcroot<String*> str)
	{
		m_p = (char*)Marshal::StringToCoTaskMemAnsi(str).ToPointer();
	}
	~CIntPtrStringAnsi() { Free(); }
	void Free()
	{ 
		if(m_p)
			Marshal::FreeCoTaskMem(IntPtr(m_p)); 
		m_p = 0;
	}
#ifdef WINLDAP_NET
	#if LDAP_UNICODE
		#error Unicode is not supported, code has to be modified to support Unicode
	#endif
	operator const PCHAR() { return m_p; }
#elif OPENLDAP_NET
	operator const char*() { return m_p; }
#endif
private:
	char* m_p;
private:
	CIntPtrStringAnsi(const CIntPtrStringAnsi&);
	CIntPtrStringAnsi& operator=(const CIntPtrStringAnsi&);
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions