Click here to Skip to main content
15,899,679 members
Home / Discussions / C#
   

C#

 
QuestionCancel from Custom Installer Pin
vSoares4-Sep-07 0:30
professionalvSoares4-Sep-07 0:30 
QuestionHow to copy all listbox items to cipboard? Pin
Abelinda814-Sep-07 0:26
Abelinda814-Sep-07 0:26 
AnswerRe: How to copy all listbox items to cipboard? Pin
Colin Angus Mackay4-Sep-07 1:49
Colin Angus Mackay4-Sep-07 1:49 
GeneralRe: How to copy all listbox items to cipboard? Pin
Abelinda814-Sep-07 4:36
Abelinda814-Sep-07 4:36 
GeneralRe: How to copy all listbox items to cipboard? Pin
Colin Angus Mackay4-Sep-07 5:03
Colin Angus Mackay4-Sep-07 5:03 
Questionremoving event handlers Pin
JoZ CaVaLLo4-Sep-07 0:09
JoZ CaVaLLo4-Sep-07 0:09 
AnswerRe: removing event handlers Pin
originSH4-Sep-07 0:11
originSH4-Sep-07 0:11 
QuestionActive Directory Pin
dorine824-Sep-07 0:01
dorine824-Sep-07 0:01 
hello,
I wrote the following program. it should be able to make changes in active directory. but it doesn't do it.
can you look at my code and say to me what does not go with?

THANK YOU



using System;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;
using System.DirectoryServices;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text;

namespace fichier
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private Button btnWriteToLDAP;
private DataTable m_dt;
//private System.Windows.Forms.TextBox textBox1;

//
// required designer variable.

private System.ComponentModel.Container components = null;
public Form1()
{
// 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.dataGrid1 = new System.Windows.Forms.DataGrid();
this.btnWriteToLDAP = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 40);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(400, 400);
this.dataGrid1.TabIndex = 0;
//
// btnWriteToLDAP
//
this.btnWriteToLDAP.Location = new System.Drawing.Point(415, 40);
this.btnWriteToLDAP.Name = "btnWriteToLDAP";
this.btnWriteToLDAP.Size = new System.Drawing.Size(75, 23);
this.btnWriteToLDAP.TabIndex = 1;
this.btnWriteToLDAP.Text = "WriteToLDAP";
this.btnWriteToLDAP.UseVisualStyleBackColor = true;
this.btnWriteToLDAP.Click += new System.EventHandler(this.btnWriteToLDAP_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(680, 425);
this.Controls.Add(this.btnWriteToLDAP);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);

}


#endregion
// the main entry point for the application
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{

// on crée une table
m_dt = new DataTable("test");
// on crée des colonnes
m_dt.Columns.Add("TelephoneNumber", System.Type.GetType("System.Int32"));
m_dt.Columns.Add("User", System.Type.GetType("System.String"));
StreamReader fichier = File.OpenText(@"h:\\export.txt");
while (fichier.Peek() >= 0)
{
// on lit une ligne et on ajoute
string ligne = fichier.ReadLine();
string[] vals = ligne.Split(';');
DataRow dr = m_dt.NewRow();
try
{
dr["TelephoneNumber"] = int.Parse(vals[0]);
dr["User"] = vals[1];
m_dt.Rows.Add(dr);
}

catch (Exception ex)
{
Console.WriteLine(ex.GetType().ToString());
Console.ReadLine();
}

}

// on genere le tableau
dataGrid1.DataSource = m_dt;
}


private void btnWriteToLDAP_Click(object sender, EventArgs e)
{

{

DirectoryEntry deUser = new DirectoryEntry("LDAP://ou=User, ou=User Office, ou=User, DC=hte,DC=intra", "don", "mamanetpapa");

DirectorySearcher searchEmploye = new DirectorySearcher(deUser);



searchEmploye.Filter = "(objectClass=user)";



// Display all Employe

foreach (SearchResult unResultat in searchEmploye.FindAll())
{

DirectoryEntry unEmploye = unResultat.GetDirectoryEntry();


}



// Modification of the telephoneNumber


foreach (SearchResult unResultat in searchEmploye.FindAll())
{

DirectoryEntry unEmploye = unResultat.GetDirectoryEntry();
foreach (DataRow row in m_dt.Rows)
{
/*if (row[0].ToString().Contains(" "))
{
string[] str = row[0].ToString().Split(" ");
}*/
MessageBox.Show(unEmploye.Properties["SAMAccountName"].Value.ToString());
if (unEmploye.Properties["SAMAccountName"].Value == row[1])
{
string temp = string.Format("{0} {1}", row[1], row[0]);
MessageBox.Show(temp);
unEmploye.Properties["telephoneNumber"].Value = row[0].ToString();
unEmploye.CommitChanges();
}
}
}

}
}

}
}








Dorine

AnswerRe: Active Directory Pin
Dave Kreskowiak4-Sep-07 5:39
mveDave Kreskowiak4-Sep-07 5:39 
QuestionI'm going crazy! C# operators Pin
Eli Nurman3-Sep-07 23:48
Eli Nurman3-Sep-07 23:48 
AnswerRe: I'm going crazy! C# operators Pin
Muammar©3-Sep-07 23:57
Muammar©3-Sep-07 23:57 
GeneralRe: I'm going crazy! C# operators Pin
originSH4-Sep-07 0:01
originSH4-Sep-07 0:01 
GeneralRe: I'm going crazy! C# operators Pin
Muammar©4-Sep-07 1:22
Muammar©4-Sep-07 1:22 
GeneralRe: I'm going crazy! C# operators Pin
originSH4-Sep-07 1:41
originSH4-Sep-07 1:41 
GeneralRe: I'm going crazy! C# operators Pin
originSH4-Sep-07 3:18
originSH4-Sep-07 3:18 
AnswerRe: I'm going crazy! C# operators Pin
originSH3-Sep-07 23:59
originSH3-Sep-07 23:59 
GeneralRe: I'm going crazy! C# operators Pin
Eli Nurman4-Sep-07 0:10
Eli Nurman4-Sep-07 0:10 
GeneralRe: I'm going crazy! C# operators Pin
originSH4-Sep-07 0:18
originSH4-Sep-07 0:18 
GeneralRe: I'm going crazy! C# operators Pin
Muammar©4-Sep-07 1:27
Muammar©4-Sep-07 1:27 
GeneralRe: I'm going crazy! C# operators Pin
originSH4-Sep-07 1:40
originSH4-Sep-07 1:40 
GeneralRe: I'm going crazy! C# operators Pin
originSH4-Sep-07 3:17
originSH4-Sep-07 3:17 
GeneralRe: I'm going crazy! C# operators Pin
Muammar©4-Sep-07 19:33
Muammar©4-Sep-07 19:33 
AnswerRe: I'm going crazy! C# operators Pin
Guffa4-Sep-07 0:08
Guffa4-Sep-07 0:08 
QuestionLoading combobox with items on form load Pin
Karlos_V3-Sep-07 23:35
Karlos_V3-Sep-07 23:35 
AnswerRe: Loading combobox with items on form load Pin
rah_sin3-Sep-07 23:43
professionalrah_sin3-Sep-07 23:43 

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.