Click here to Skip to main content
13,558,160 members
Click here to Skip to main content
Add your own
alternative version


49 bookmarked
Posted 26 Mar 2008
Licenced CPOL

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

, 26 Mar 2008
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

You may also be interested in...


Comments and Discussions

GeneralMy vote of 4 Pin
gino_montano26-Jun-12 6:57
membergino_montano26-Jun-12 6:57 
Generalthanks Pin
mohmeh8311-Jul-09 20:27
membermohmeh8311-Jul-09 20:27 
GeneralThanks Pin
sebbry12-Jun-09 0:38
membersebbry12-Jun-09 0:38 
QuestionChange Password Pin
thanhchiho18-Nov-08 17:50
memberthanhchiho18-Nov-08 17:50 
GeneralresetPassword Pin
-Sean-1-Nov-08 16:28
member-Sean-1-Nov-08 16:28 
GeneralRe: resetPassword Pin
-Sean-1-Nov-08 17:12
member-Sean-1-Nov-08 17:12 
GeneralRe: resetPassword Pin
xExTxCx4-Nov-08 4:46
memberxExTxCx4-Nov-08 4:46 
Generalcool Pin
Kipetcoff18-Sep-08 21:31
memberKipetcoff18-Sep-08 21:31 
GeneralWon't open in VS 2005 Pin
DABBee31-Mar-08 20:14
memberDABBee31-Mar-08 20:14 
GeneralRe: Won't open in VS 2005 Pin
xExTxCx1-Apr-08 5:27
memberxExTxCx1-Apr-08 5:27 
GeneralGreat work Pin
R%S26-Mar-08 20:34
memberR%S26-Mar-08 20:34 
GeneralRe: Great work Pin
xExTxCx27-Mar-08 5:45
memberxExTxCx27-Mar-08 5:45 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180515.1 | Last Updated 26 Mar 2008
Article Copyright 2008 by xExTxCx
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid