Click here to Skip to main content
Click here to Skip to main content

Velde.Utilities - C# Utility Class for Active Directory, Databases, Files, Networking etc.

, 26 Mar 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
C# Utility class for Active Directory, databases, files, networking etc.


This utility class was written to simplify common tasks relating initially to Active Directory and SQL. It has since been updated to include file manipulation, networking and basic dates.


Many of the Active Directory functions were reworked from The Code Project article by thund3rstruck.

Using the Code

Velde.Utilities consists of several classes. Each could be split off into their own libraries.

This class requires Interop.ActiveDs.dll - included.

Active Directory - Velde.Utilities.AD


// Instantiate the AD Class

Velde.Utilities.AD AD = new Velde.Utilities.AD();

//if you wish to enable debugging
AD.debug = true; // this will cause any errors to be shown via MessageBox

// the constructor populates the domainDN field with the distinguishedName of the 
// domain to be used by LDAP in the rest of the functions. 

//What if we want to reset the password for Joe Smith, username: jsmith??
// we must do two things, get the user's distinguishedName, then reset the password.
string accountDN = AD.returnProperty("jsmith", "distinguishedName");

if(! AD.resetPasword(accountDN, "myNew$uperc001P@$$W0RD")
    MessageBox.Show("Password was not reset!!");

//Create a user account for user Kevin Lee
//                    baseDN for user                        
//           UID     password     firstName  lastName
            "klee","!Password1", "Kevin", "Lee");     

//Force Kevin Lee to reset his password
AD.setProperty("klee","pwdLastSet", 0); //forced to reset password on next logon

//deny Kevin Lee the ability to change his password
string kevinAccountDN = AD.returnProperty("klee", "distinguishedName");

Database - Velde.Utilities.Database.?

Currently Supported: Access, Excel, SQL, Visual FoxPro.


// Instantiate the SQL Class
// (database classes: Access, Excel, SQL, VFoxPro)
Velde.Utilities.Database.SQL sql = new Velde.Utilities.Database.SQL();

//if you wish to enable debugging
sql.debug = true;

//setup server connection
sql.server = "name or ip of server"
sql.database = "name of database";
sql.username = "username";
sql.password = "password";

//get some information populated to the dataTable
sql.execQuery("SELECT * FROM table WHERE columnName LIKE 'pattern'");

//display the results
for(int i=0;i<sql.dt.Rows.Count;i++)

//update the datatable
sql.dt.Rows[rowToModify]["columnName"] = "test";

//update the database to match the changes in the datatable
sql.updateTable(sql.da, sql.dt);

Network - Velde.Utilities.Network


// Instantiate the Network Class
Velde.Utilities.Network net = new Velde.Utilities.Network;

//if you wish to enable debugging
net.debug= true;

//check to see if a host is on the network
if(net.isAlive("IP or DNS Name"))
    Console.WriteLine("Host is alive!");

//check to see if a host is listening on the smtp port
if(net.isAlive("IP", 25))
    Console.WriteLine("Server accepting connections.");

//send an email-  from, to, subject, body, bodyHTML, server, port
net.sendMail("","", "Subject", 
    "body", true/false, "serverName or IP", 25);

//shutdown remote host - requires admin on remote machine
if(net.killHost("IP or DNS name of host"))
    Console.WriteLine("Host accepted shutdown command.");

Classes Not Shown

files.JPG time.JPG


Hopefully, this set of classes can save you some time, or give you a better idea of how to do certain tasks. Let me know if you decide to use this in any of your projects, or if you think that I'm way off base.


  • 3-26-2008 - Article uploaded


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


About the Author


United States United States
No Biography provided

Comments and Discussions

GeneralMy vote of 4 Pinmembergino_montano26-Jun-12 7:57 
Generalthanks Pinmembermohmeh8311-Jul-09 21:27 
GeneralThanks Pinmembersebbry12-Jun-09 1:38 
QuestionChange Password Pinmemberthanhchiho18-Nov-08 18:50 
GeneralresetPassword Pinmember-Sean-1-Nov-08 17:28 
GeneralRe: resetPassword Pinmember-Sean-1-Nov-08 18:12 
GeneralRe: resetPassword PinmemberxExTxCx4-Nov-08 5:46 
Generalcool PinmemberKipetcoff18-Sep-08 22:31 
GeneralWon't open in VS 2005 PinmemberDABBee31-Mar-08 21:14 
GeneralRe: Won't open in VS 2005 PinmemberxExTxCx1-Apr-08 6:27 
GeneralGreat work PinmemberR%S26-Mar-08 21:34 
GeneralRe: Great work PinmemberxExTxCx27-Mar-08 6:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141216.1 | Last Updated 26 Mar 2008
Article Copyright 2008 by xExTxCx
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid