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:
- 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.
- Commonly used text streaming, file I/O functions.
- 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.
- 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 GPCL_Source.zip 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:
WernerReyneke.GPCL.DataPlus xml_q = new DataPlus();
System.Data.DataRow drows =
foreach( DataRow r in drows )
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
WernerReyneke.GPCL.LDAPPlus Auth = new LDAPPlus();
string name = Auth.Authenticate_Against_LDAP("LDAP (Active" +
" Directory Server) Name","NT username","password");
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.