Click here to Skip to main content
15,897,273 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow pass an event to a sub Pin
Narenge31-Oct-07 3:37
Narenge31-Oct-07 3:37 
AnswerRe: How pass an event to a sub Pin
svanwass31-Oct-07 5:13
svanwass31-Oct-07 5:13 
AnswerRe: How pass an event to a sub Pin
AliAmjad31-Oct-07 5:13
AliAmjad31-Oct-07 5:13 
AnswerRe: How pass an event to a sub Pin
Dave Kreskowiak31-Oct-07 6:32
mveDave Kreskowiak31-Oct-07 6:32 
AnswerRe: How pass an event to a sub Pin
Narenge31-Oct-07 12:25
Narenge31-Oct-07 12:25 
Questionconnecting an Access database to visual basic.net 2005 Pin
Ian Wells31-Oct-07 2:21
Ian Wells31-Oct-07 2:21 
AnswerRe: connecting an Access database to visual basic.net 2005 Pin
svanwass31-Oct-07 5:30
svanwass31-Oct-07 5:30 
Questionneed help with vb.net and active directory. Pin
kingpin200531-Oct-07 2:17
kingpin200531-Oct-07 2:17 
hi,

i am designing an application which helps in creating a user account.
the problem i am stuck with is i want the user accounts to be created in there respective OUs but the application is creating the user accounts in default users container.

here is the code that i have written.


/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Inclive;
using System.DirectoryServices;

namespace ADHelp
{
///
/// Summary description for Form1.
///

public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button CmdClose;
private System.Windows.Forms.Button CmdCreate;
private System.Windows.Forms.TextBox TxtUsername;
private System.Windows.Forms.TextBox TxtDescription;
private System.Windows.Forms.TextBox TxtDomain;
private System.Windows.Forms.TextBox TxtDomainController;
private System.Windows.Forms.TextBox TxtAdminUser;
private System.Windows.Forms.TextBox TxtAdminPassword;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button CmdEnable;
private System.Windows.Forms.Button CmdDisable;
private System.Windows.Forms.Button CmdExists;
private System.Windows.Forms.TextBox TxtUserPassword;
private System.Windows.Forms.TextBox TxtUserGroup;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button CmdPassword;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Button CmdGroup;
private System.Windows.Forms.Label label8;
private LinkLabel lnkWrapper;
private Label label9;
private Label labelDept;
private RadioButton OU1;
private RadioButton OU2;
private RadioButton OU3;
private Label hdrive;
private TextBox TXTHDrive;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public MainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.CmdClose = new System.Windows.Forms.Button();
this.CmdCreate = new System.Windows.Forms.Button();
this.TxtUsername = new System.Windows.Forms.TextBox();
this.TxtDomain = new System.Windows.Forms.TextBox();
this.TxtDomainController = new System.Windows.Forms.TextBox();
this.TxtAdminUser = new System.Windows.Forms.TextBox();
this.TxtAdminPassword = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label();
this.CmdEnable = new System.Windows.Forms.Button();
this.CmdDisable = new System.Windows.Forms.Button();
this.CmdExists = new System.Windows.Forms.Button();
this.TxtUserPassword = new System.Windows.Forms.TextBox();
this.TxtUserGroup = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.CmdPassword = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.CmdGroup = new System.Windows.Forms.Button();
this.label8 = new System.Windows.Forms.Label();
this.lnkWrapper = new System.Windows.Forms.LinkLabel();
this.label9 = new System.Windows.Forms.Label();
this.TxtDescription = new System.Windows.Forms.TextBox();
this.labelDept = new System.Windows.Forms.Label();
this.OU1 = new System.Windows.Forms.RadioButton();
this.OU2 = new System.Windows.Forms.RadioButton();
this.OU3 = new System.Windows.Forms.RadioButton();
this.hdrive = new System.Windows.Forms.Label();
this.TXTHDrive = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// CmdClose
//
this.CmdClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.CmdClose.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.CmdClose.Location = new System.Drawing.Point(232, 366);
this.CmdClose.Name = "CmdClose";
this.CmdClose.Size = new System.Drawing.Size(75, 23);
this.CmdClose.TabIndex = 0;
this.CmdClose.Text = "Close";
this.CmdClose.Click += new System.EventHandler(this.CmdClose_Click);
//
// CmdCreate
//
this.CmdCreate.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.CmdCreate.Location = new System.Drawing.Point(233, 195);
this.CmdCreate.Name = "CmdCreate";
this.CmdCreate.Size = new System.Drawing.Size(75, 23);
this.CmdCreate.TabIndex = 1;
this.CmdCreate.Text = "Create";
this.CmdCreate.Click += new System.EventHandler(this.CmdCreate_Click);
//
// TxtUsername
//
this.TxtUsername.Location = new System.Drawing.Point(88, 195);
this.TxtUsername.Name = "TxtUsername";
this.TxtUsername.Size = new System.Drawing.Size(136, 20);
this.TxtUsername.TabIndex = 2;
//
// TxtDomain
//
this.TxtDomain.Enabled = false;
this.TxtDomain.Location = new System.Drawing.Point(156, 28);
this.TxtDomain.Name = "TxtDomain";
this.TxtDomain.Size = new System.Drawing.Size(128, 20);
this.TxtDomain.TabIndex = 3;
this.TxtDomain.Text = "testing.com";
//
// TxtDomainController
//
this.TxtDomainController.Enabled = false;
this.TxtDomainController.Location = new System.Drawing.Point(156, 56);
this.TxtDomainController.Name = "TxtDomainController";
this.TxtDomainController.Size = new System.Drawing.Size(128, 20);
this.TxtDomainController.TabIndex = 4;
this.TxtDomainController.Text = "192.168.1.3";
//
// TxtAdminUser
//
this.TxtAdminUser.Location = new System.Drawing.Point(156, 84);
this.TxtAdminUser.Name = "TxtAdminUser";
this.TxtAdminUser.Size = new System.Drawing.Size(128, 20);
this.TxtAdminUser.TabIndex = 5;
this.TxtAdminUser.Text = "Administrator";
//
// TxtAdminPassword
//
this.TxtAdminPassword.Location = new System.Drawing.Point(156, 112);
this.TxtAdminPassword.Name = "TxtAdminPassword";
this.TxtAdminPassword.PasswordChar = '*';
this.TxtAdminPassword.Size = new System.Drawing.Size(128, 20);
this.TxtAdminPassword.TabIndex = 6;
this.TxtAdminPassword.Text = "Password";
//
// label1
//
this.label1.Location = new System.Drawing.Point(12, 28);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 16);
this.label1.TabIndex = 7;
this.label1.Text = "Domain Name:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(12, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(148, 16);
this.label2.TabIndex = 8;
this.label2.Text = "Domain Computer Name/IP:";
//
// label3
//
this.label3.Location = new System.Drawing.Point(12, 84);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(136, 16);
this.label3.TabIndex = 9;
this.label3.Text = "Administrator Username:";
//
// label4
//
this.label4.Location = new System.Drawing.Point(12, 112);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(136, 16);
this.label4.TabIndex = 10;
this.label4.Text = "Administrator Password:";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.TxtAdminUser);
this.groupBox1.Controls.Add(this.TxtDomainController);
this.groupBox1.Controls.Add(this.TxtDomain);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.TxtAdminPassword);
this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.groupBox1.Location = new System.Drawing.Point(20, 35);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(296, 144);
this.groupBox1.TabIndex = 11;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Connection Information";
//
// label5
//
this.label5.Location = new System.Drawing.Point(12, 199);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(64, 16);
this.label5.TabIndex = 12;
this.label5.Text = "Username:";
//
// CmdEnable
//
this.CmdEnable.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.CmdEnable.Location = new System.Drawing.Point(233, 281);
this.CmdEnable.Name = "CmdEnable";
this.CmdEnable.Size = new System.Drawing.Size(75, 23);
this.CmdEnable.TabIndex = 13;
this.CmdEnable.Text = "Enable";
this.CmdEnable.Click += new System.EventHandler(this.CmdEnable_Click);
//
// CmdDisable
//
this.CmdDisable.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.CmdDisable.Location = new System.Drawing.Point(233, 310);
this.CmdDisable.Name = "CmdDisable";
this.CmdDisable.Size = new System.Drawing.Size(75, 23);
this.CmdDisable.TabIndex = 16;
this.CmdDisable.Text = "Disable";
this.CmdDisable.Visible = false;
this.CmdDisable.Click += new System.EventHandler(this.CmdDisable_Click);
//
// CmdExists
//
this.CmdExists.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.CmdExists.Location = new System.Drawing.Point(233, 224);
this.CmdExists.Name = "CmdExists";
this.CmdExists.Size = new System.Drawing.Size(75, 23);
this.CmdExists.TabIndex = 17;
this.CmdExists.Text = "Exists";
this.CmdExists.Click += new System.EventHandler(this.CmdExists_Click);
//
// TxtUserPassword
//
this.TxtUserPassword.Location = new System.Drawing.Point(88, 219);
this.TxtUserPassword.Name = "TxtUserPassword";
this.TxtUserPassword.PasswordChar = '*';
this.TxtUserPassword.Size = new System.Drawing.Size(136, 20);
this.TxtUserPassword.TabIndex = 18;
//
// TxtUserGroup
//
this.TxtUserGroup.Enabled = false;
this.TxtUserGroup.Location = new System.Drawing.Point(87, 321);
this.TxtUserGroup.Name = "TxtUserGroup";
this.TxtUserGroup.Size = new System.Drawing.Size(137, 20);
this.TxtUserGroup.TabIndex = 19;
this.TxtUserGroup.Visible = false;
//
// label6
//
this.label6.Location = new System.Drawing.Point(12, 223);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(64, 16);
this.label6.TabIndex = 20;
this.label6.Text = "Password:";
//
// CmdPassword
//
this.CmdPassword.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.CmdPassword.Location = new System.Drawing.Point(233, 252);
this.CmdPassword.Name = "CmdPassword";
this.CmdPassword.Size = new System.Drawing.Size(75, 23);
this.CmdPassword.TabIndex = 21;
this.CmdPassword.Text = "Set Password";
this.CmdPassword.Click += new System.EventHandler(this.CmdPassword_Click);
//
// label7
//
this.label7.Enabled = false;
this.label7.Location = new System.Drawing.Point(9, 325);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(72, 16);
this.label7.TabIndex = 22;
this.label7.Text = "Group Name:";
this.label7.Visible = false;
//
// CmdGroup
//
this.CmdGroup.Enabled = false;
this.CmdGroup.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.CmdGroup.Location = new System.Drawing.Point(233, 339);
this.CmdGroup.Name = "CmdGroup";
this.CmdGroup.Size = new System.Drawing.Size(75, 23);
this.CmdGroup.TabIndex = 23;
this.CmdGroup.Text = "Set Group";
this.CmdGroup.Visible = false;
this.CmdGroup.Click += new System.EventHandler(this.CmdGroup_Click);
//
// label8
//
this.label8.BackColor = System.Drawing.Color.Transparent;
this.label8.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label8.ForeColor = System.Drawing.Color.SaddleBrown;
this.label8.Location = new System.Drawing.Point(16, 8);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(284, 24);
this.label8.TabIndex = 24;
this.label8.Text = "Create User Account";
//
// lnkWrapper
//
this.lnkWrapper.Location = new System.Drawing.Point(-1, 370);
this.lnkWrapper.Name = "lnkWrapper";
this.lnkWrapper.Size = new System.Drawing.Size(144, 20);
this.lnkWrapper.TabIndex = 25;
this.lnkWrapper.TabStop = true;
this.lnkWrapper.Text = "Created by Hitender Yadav";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(12, 246);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(67, 13);
this.label9.TabIndex = 26;
this.label9.Text = "Employee ID";
//
// TxtDescription
//
this.TxtDescription.Location = new System.Drawing.Point(88, 243);
this.TxtDescription.Name = "TxtDescription";
this.TxtDescription.Size = new System.Drawing.Size(136, 20);
this.TxtDescription.TabIndex = 27;
//
// labelDept
//
this.labelDept.AutoSize = true;
this.labelDept.Location = new System.Drawing.Point(11, 271);
this.labelDept.Name = "labelDept";
this.labelDept.Size = new System.Drawing.Size(62, 13);
this.labelDept.TabIndex = 28;
this.labelDept.Text = "Department";
//
// OU1
//
this.OU1.AutoSize = true;
this.OU1.Location = new System.Drawing.Point(87, 271);
this.OU1.Name = "OU1";
this.OU1.Size = new System.Drawing.Size(46, 17);
this.OU1.TabIndex = 29;
this.OU1.TabStop = true;
this.OU1.Text = "OU1";
this.OU1.UseVisualStyleBackColor = true;
//
// OU2
//
this.OU2.AutoSize = true;
this.OU2.Location = new System.Drawing.Point(137, 271);
this.OU2.Name = "OU2";
this.OU2.Size = new System.Drawing.Size(43, 17);
this.OU2.TabIndex = 30;
this.OU2.TabStop = true;
this.OU2.Text = "OU2";
this.OU2.UseVisualStyleBackColor = true;
//
// OU3
//
this.OU3.AutoSize = true;
this.OU3.Location = new System.Drawing.Point(180, 271);
this.OU3.Name = "OU3";
this.OU3.Size = new System.Drawing.Size(47, 17);
this.OU3.TabIndex = 31;
this.OU3.TabStop = true;
this.OU3.Text = "OU3";
this.OU3.UseVisualStyleBackColor = true;
//
// hdrive
//
this.hdrive.AutoSize = true;
this.hdrive.Location = new System.Drawing.Point(11, 291);
this.hdrive.Name = "hdrive";
this.hdrive.Size = new System.Drawing.Size(63, 13);
this.hdrive.TabIndex = 32;
this.hdrive.Text = "Home Drive";
//
// TXTHDrive
//
this.TXTHDrive.Enabled = false;
this.TXTHDrive.Location = new System.Drawing.Point(88, 293);
this.TXTHDrive.Name = "TXTHDrive";
this.TXTHDrive.Size = new System.Drawing.Size(136, 20);
this.TXTHDrive.TabIndex = 33;
this.TXTHDrive.Text = "\\\\in-ndafs01\\user\\";

//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(322, 402);
this.Controls.Add(this.TXTHDrive);
this.Controls.Add(this.hdrive);
this.Controls.Add(this.OU3);
this.Controls.Add(this.OU2);
this.Controls.Add(this.OU1);
this.Controls.Add(this.labelDept);
this.Controls.Add(this.TxtDescription);
this.Controls.Add(this.label9);
this.Controls.Add(this.lnkWrapper);
this.Controls.Add(this.label8);
this.Controls.Add(this.CmdGroup);
this.Controls.Add(this.label7);
this.Controls.Add(this.CmdPassword);
this.Controls.Add(this.label6);
this.Controls.Add(this.TxtUserGroup);
this.Controls.Add(this.TxtUserPassword);
this.Controls.Add(this.CmdExists);
this.Controls.Add(this.CmdDisable);
this.Controls.Add(this.CmdEnable);
this.Controls.Add(this.label5);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.TxtUsername);
this.Controls.Add(this.CmdCreate);
this.Controls.Add(this.CmdClose);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "MainForm";
this.Text = "Create New User Accounts";
this.Load += new System.EventHandler(this.MainForm_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new MainForm());
}

private void CmdClose_Click(object sender, System.EventArgs e)
{
this.Close();
}

private void CmdCreate_Click(object sender, System.EventArgs e)
{
if (!this.IsValid())
return;

try
{
DotnetAD.ADAdminUser = this.TxtAdminUser.Text;
DotnetAD.ADAdminPassword = this.TxtAdminPassword.Text;
DotnetAD.ADFullPath = "LDAP://" + this.TxtDomainController.Text;
DotnetAD.ADServer = this.TxtDomain.Text;

DirectoryEntry user = DotnetAD.CreateNewUser(this.TxtUsername.Text);
if (user != null)
{
MessageBox.Show(this, "The user has been created.", "Create User");
user.Close();
user.Dispose();
}
else
MessageBox.Show(this, "Unable to create user.", "Create User");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}

DirectoryEntry Description = DotnetAD.SetProperty(Description, "description", TxtDescription.Text);
if (OU1.Select=true)
{

try
{
// Bind to the OU1 container, add a new User.
DirectoryEntry de = new DirectoryEntry("LDAP://CN=OU1,DC=Testing,DC=com");
}
catch (Exception Exception1)
{
// If a COMException is thrown, then the following code example can catch the text of the error.
// For more information about handling COM exceptions, see Handling Errors.
System.Runtime.InteropServices.COMException COMEx =
(System.Runtime.InteropServices.COMException)Exception1;
Console.WriteLine(COMEx.ErrorCode);
}

//DirectoryEntry newGroup = de.Children.Add("CN=Sales", "group");newGroup.CommitChanges();
//DirectoryEntry newContact = de.Children.Add("CN=New Contact", "contact");newContact.CommitChanges();

}
if (OU2.Select = true)
{
try
{
// Bind to the OU2 container, add a new User.
DirectoryEntry de = new DirectoryEntry("LDAP://CN=OU2,DC=Testing,DC=com");
}
catch (Exception Exception1)
{
// If a COMException is thrown, then the following code example can catch the text of the error.
// For more information about handling COM exceptions, see Handling Errors.
System.Runtime.InteropServices.COMException COMEx =
(System.Runtime.InteropServices.COMException)Exception1;
Console.WriteLine(COMEx.ErrorCode);
}
//try
//{
// DirectoryEntry de = new DirectoryEntry("LDAP://CN=OU2,DC=Testing,DC=com");
//}

}
if (OU3.Select = true)
{
try
{
// Bind to the OU3 container, add a new User.
DirectoryEntry de = new DirectoryEntry("LDAP://CN=OU3,DC=Testing,DC=com");
}
catch (Exception Exception1)
{
// If a COMException is thrown, then the following code example can catch the text of the error.
// For more information about handling COM exceptions, see Handling Errors.
System.Runtime.InteropServices.COMException COMEx =
(System.Runtime.InteropServices.COMException)Exception1;
Console.WriteLine(COMEx.ErrorCode);
}
// try
//{
//DirectoryEntry de = new DirectoryEntry("LDAP://CN=OU3,DC=Testing,DC=com");
//}

}
//DirectoryEntry description = DotnetAD.SetProperty(Description,"description",TxtDescription);


}


private bool IsValid()
{
if (this.TxtAdminUser.Text.Length <= 0)
{
MessageBox.Show(this, "Must provide an administrative user to connect with.", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}

if (this.TxtAdminPassword.Text.Length <= 0)
{
MessageBox.Show(this, "Must provide a password for the administrative user.", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}

if (this.TxtDomain.Text.Length <= 0)
{
MessageBox.Show(this, "Must provide a domain name to connect with.", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}

if (this.TxtDomainController.Text.Length <= 0)
{
MessageBox.Show(this, "Must provide the name of the domain controller.", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}

if (this.TxtUsername.Text.Length <= 0)
{
MessageBox.Show(this, "Must provide the username of the user to create/modify.", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}

return true;
}

private void CmdEnable_Click(object sender, System.EventArgs e)
{
if (!this.IsValid())
return;

try
{
DotnetAD.ADAdminUser = this.TxtAdminUser.Text;
DotnetAD.ADAdminPassword = this.TxtAdminPassword.Text;
DotnetAD.ADFullPath = "LDAP://" + this.TxtDomainController.Text;
DotnetAD.ADServer = this.TxtDomain.Text;

DotnetAD.EnableUserAccount(this.TxtUsername.Text);
MessageBox.Show(this, "User has been enabled.", "Enable User");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

private void CmdDisable_Click(object sender, System.EventArgs e)
{
if (!this.IsValid())
return;

try
{
DotnetAD.ADAdminUser = this.TxtAdminUser.Text;
DotnetAD.ADAdminPassword = this.TxtAdminPassword.Text;
DotnetAD.ADFullPath = "LDAP://" + this.TxtDomainController.Text;
DotnetAD.ADServer = this.TxtDomain.Text;

DotnetAD.DisableUserAccount(this.TxtUsername.Text);
MessageBox.Show(this, "User has been disabled.", "Disable User");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

private void CmdExists_Click(object sender, System.EventArgs e)
{
if (!this.IsValid())
return;

try
{
DotnetAD.ADAdminUser = this.TxtAdminUser.Text;
DotnetAD.ADAdminPassword = this.TxtAdminPassword.Text;
DotnetAD.ADFullPath = "LDAP://" + this.TxtDomainController.Text;
DotnetAD.ADServer = this.TxtDomain.Text;

if (DotnetAD.UserExists(this.TxtUsername.Text))
MessageBox.Show(this, "The user exists.", "User Exists");
else
MessageBox.Show(this, "The user does not exist.", "User Exists");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

private void CmdPassword_Click(object sender, System.EventArgs e)
{
if (!this.IsValid())
return;

if (this.TxtUserPassword.Text.Length <= 0)
{
MessageBox.Show(this, "Must provide a password for the user.", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

try
{
DotnetAD.ADAdminUser = this.TxtAdminUser.Text;
DotnetAD.ADAdminPassword = this.TxtAdminPassword.Text;
DotnetAD.ADFullPath = "LDAP://" + this.TxtDomainController.Text;
DotnetAD.ADServer = this.TxtDomain.Text;

DotnetAD.SetUserPassword(this.TxtUsername.Text, this.TxtUserPassword.Text);
MessageBox.Show(this, "Password has been set.", "Set Password");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

private void CmdGroup_Click(object sender, System.EventArgs e)
{
if (!this.IsValid())
return;

if (this.TxtUserGroup.Text.Length <= 0)
{
MessageBox.Show(this, "Must provide a group for the user.", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

try
{
DotnetAD.ADAdminUser = this.TxtAdminUser.Text;
DotnetAD.ADAdminPassword = this.TxtAdminPassword.Text;
DotnetAD.ADFullPath = "LDAP://" + this.TxtDomainController.Text;
DotnetAD.ADServer = this.TxtDomain.Text;

DotnetAD.AddUserToGroup(this.TxtUsername.Text, this.TxtUserGroup.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}


private void lnkWrapper_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
// Determine which link was clicked within the LinkLabel.
lnkWrapper.Links[lnkWrapper.Links.IndexOf(e.Link)].Visited = false;
// Display the appropriate link based on the value of the
// LinkData property of the Link object.
System.Diagnostics.Process.Start(e.Link.LinkData.ToString());

}

private void MainForm_Load(object sender, System.EventArgs e)
{
this.lnkWrapper.Links.Add(0,this.lnkWrapper.Text.Length,"hyadav@csc.com");
}

}
}

/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/


Please help me to get this thing done as soon as possible.

Need Help urgently and Badly.

KingPin Confused | :confused:
AnswerRe: need help with vb.net and active directory. Pin
Dave Kreskowiak31-Oct-07 6:13
mveDave Kreskowiak31-Oct-07 6:13 
GeneralRe: need help with vb.net and active directory. Pin
kingpin200531-Oct-07 21:53
kingpin200531-Oct-07 21:53 
QuestionArray - Structure problem Pin
Benny_Lava31-Oct-07 0:38
Benny_Lava31-Oct-07 0:38 
AnswerRe: Array - Structure problem Pin
pmarfleet31-Oct-07 3:33
pmarfleet31-Oct-07 3:33 
AnswerRe: Array - Structure problem Pin
Dave Kreskowiak31-Oct-07 6:07
mveDave Kreskowiak31-Oct-07 6:07 
QuestionPath to Installed Application Pin
SekharOne30-Oct-07 23:41
SekharOne30-Oct-07 23:41 
AnswerRe: Path to Installed Application Pin
Dave Kreskowiak31-Oct-07 6:05
mveDave Kreskowiak31-Oct-07 6:05 
GeneralRe: Path to Installed Application Pin
SekharOne1-Nov-07 0:39
SekharOne1-Nov-07 0:39 
QuestionKey Handling Pin
fazeepk30-Oct-07 23:00
fazeepk30-Oct-07 23:00 
AnswerRe: Key Handling Pin
Salman Sheikh30-Oct-07 23:35
Salman Sheikh30-Oct-07 23:35 
QuestionData Binding Pin
ejaz_pk30-Oct-07 22:12
ejaz_pk30-Oct-07 22:12 
AnswerRe: Data Binding Pin
Dave Kreskowiak31-Oct-07 5:21
mveDave Kreskowiak31-Oct-07 5:21 
GeneralRe: Data Binding Pin
ejaz_pk31-Oct-07 21:08
ejaz_pk31-Oct-07 21:08 
GeneralRe: Data Binding Pin
John_Adams1-Nov-07 1:16
John_Adams1-Nov-07 1:16 
GeneralRe: Data Binding Pin
ejaz_pk1-Nov-07 2:05
ejaz_pk1-Nov-07 2:05 
QuestionHow to get newest file through VB Pin
Support12330-Oct-07 20:23
Support12330-Oct-07 20:23 
AnswerRe: How to get newest file through VB Pin
C1AllenS30-Oct-07 23:32
C1AllenS30-Oct-07 23:32 

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.