Click here to Skip to main content
13,797,537 members
Click here to Skip to main content
Add your own
alternative version


17 bookmarked
Posted 17 Jan 2006

XML Querying, Text Streaming, Debug Capture, and LDAP

, 17 Jan 2006
Rate this:
Please Sign up or sign in to vote.
Library containing functions for XML Querying, Text Streaming, Debug Capture and LDAP.


This GPCL (General Purpose Code Library) contains some general C# code functions that I use quite often. Please feel free to use the source code and implementation samples as freely as you like, and do not hesitate to tell me what you think of it.

Currently, it contains the following:

  1. XML-Querying capability. I am not aware of any easier and quicker way to query a regular XML file. If anyone of you knows of a better way, please add it to this library and let me know.
  2. Commonly used text streaming, file I/O functions.
  3. LDAP-Querying capability. You can authenticate credentials against an LDAP (Active Directory) server in just a few lines of code in any application you need to build in such integration.
  4. Send-To-Debug listener function. This function sends the supplied debug/error message, as well as the originating application name and function/procedure location within the code, to the Debug listener (same as Debug.WriteLine). A tool such as DebugView from Sysinternals can pick up its messages.

Using the code

Use the source code from as you like, for instance, by copying the functions into your own general purpose code library, or simply add the GPCL.dll as a reference to your project and start using its handy and easy (I hope!) functions in your code.

The source code as well as the demo project is thoroughly commented and explained within the code itself, so I'll just list two pieces of code as bait:

// Remember to add a reference to the library
// in any applications you wish to use the library:
       using WernerReyneke.GPCL;
// Query XML - implementation example:

//Create an instance of the DataPlus class 
//in the WernerReyneke.GPCL namespace
WernerReyneke.GPCL.DataPlus xml_q = new DataPlus();
//Set a DataRow[] object equal to the QueryXML function
//The QueryXML function returns a DataRow[] object(set of data rows)
//By passing sCatalog= B as the value of 
//the where_criteria and * as the value of the sorting
//parameters,the data is filtered to return 
//only rows where sCatalog= B and is ordered
//Ascending according to theprimary key column
System.Data.DataRow[] drows = 
  "sShortText DESC","ipkPrimaryID");
//Loop through each row of data
foreach( DataRow r in drows )
    //Display the value of the sShortText column 
    //(see sample XML file: SampleXMLFile.XML 
    //in the \bin\Debug directory)

The above code will query the XML file you provide, according to the where criteria and sorting order specified. The returned data is read back from a regular DataRow[] object.

// LDAP Authentication - implementation example:
WernerReyneke.GPCL.LDAPPlus Auth = new LDAPPlus();
//provide the Active Directory Server Name, 
//NT username (your regular NT username
//and password you use to log on to your Windows Network
string name = Auth.Authenticate_Against_LDAP("LDAP (Active" + 
              " Directory Server) Name","NT username","password");

// The name variable will contain either failure info, or the valid
//name of the AD Server you're querying.

The above code will authenticate the credentials you pass against LDAP (Active Directory), and either return a failure message, or, in case of success, the valid name of the domain controller on AD. I recently developed a Web application for a large international petroleum company's Human Resources department, in ASP.NET, where the security/logon requirement was to integrate with Active directory (LDAP), so that no extra database of separate user accounts was necessary, but that the application use the existing users on Active Directory.

That's just two nice functions. Enjoy it, and all feedback is welcome.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.181207.3 | Last Updated 17 Jan 2006
Article Copyright 2006 by Werner.Reyneke
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid