salut à tous,
me revoila de nouveau avec un nouveau problème(faute à mon chef).je prie que vous puissiez m' aidez.
merci d' avance.
en fait voila mon problème:
j'ai deux petits programmes ecrits:
le premier recupère les données d' un fichier CSV et le met dans un tableau à deux dimensions
j'avais au départ quelque chose de la sorte:
100;SG
11;SAS
...
...
...
et puis je me retrouve avec quelque chose du genre
TEL USER
110 SG
111 SAS
...
...
...
le deuxieme programme fait une recherche sur un user dans mon active directory et quand il l' a trouvé il lui assigne un numéro de telephone que j'aurais au préalable defini
en fait je voudrais relier ces deux programmes de telles facon qu'il lise chaque ligne de mon tableau et qu'il puisse directement assigner les numéros de telephone dans active directory.
c' est à dire:
il lit la premiere ligne de mon tableau il trouve les initiales SG , le cherche dans mon active directory et lui assigne directement le numéro qui est dans le tableau avec SG. ainsi de suite pour tout les users de mon domaine.
est ce que vous croyez que c' est possible?
merci infiniment de l' aide que vous m' apporterez
cordialement
pour plus de details voila mes programmes:
le 1er:
namespace fichier
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
//private System.Windows.Forms.TextBox textBox1;
//<summary>
// 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();
((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 = "datgrid1";
this.dataGrid1.Size = new System.Drawing.Size(400, 400);
this.dataGrid1.TabIndex = 0;
// Form1
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(680, 425);
//this.Controls.Add(this.textBox1);
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
DataTable dt = new DataTable("test");
// on crée des colonnes
dt.Columns.Add("TelephoneNumber", System.Type.GetType("System.Int32"));
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 = dt.NewRow();
try
{
dr["TelephoneNumber"] = int.Parse(vals[0]);
dr["User"] = vals[1];
dt.Rows.Add(dr);
}
catch (Exception ex)
{
Console.WriteLine(ex.GetType().ToString());
Console.ReadLine();
}
}
// on genere le tableau
dataGrid1.DataSource = dt;
}
}
}
le 2eme:
namespace TestAD
{
class Program
{
public static void Main(string[] args)
{
try
{
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();
if (unEmploye.Properties["SAMAccountName"].Value.ToString() == "sg")
{
// Changing the telephoneNumber
unEmploye.Properties["telephoneNumber"].Value = "110";
// Commit the modification
unEmploye.CommitChanges();
}
PS: J'espere que ca ne fait pas trop long
merci une fois de plus.