Click here to Skip to main content
15,898,035 members
Home / Discussions / Visual Basic
   

Visual Basic

 
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 
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 
i want to implement if condition because i want to get users created in there respective OU.

if you take a look at the following code :

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);


this helps in creating a user account, now i am trying to use if condition so that if ou1 or ou2 or ou3 the user should be created in that respective OU.

so please let me know how and what should i change in that code so that the user should get created in there respective OU.

Kingpin
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 
GeneralRe: How to get newest file through VB Pin
Support12331-Oct-07 1:39
Support12331-Oct-07 1:39 
AnswerRe: How to get newest file through VB Pin
Aftab Sindhi31-Oct-07 7:35
Aftab Sindhi31-Oct-07 7:35 

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.