1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
private ArrayList _employes;
public ArrayList Employes
{
get{return this._employes;}
set{this._employes = value;}
}
[WebMethod]
public string Connexion(string nom, string prenom)
{
_employes = new ArrayList();
nom = nom + "*";
prenom = prenom + "*";
try
{
DirectoryEntry Ldap = new DirectoryEntry("LDAP://************);
DirectorySearcher searcher = new DirectorySearcher(Ldap);
searcher.Filter = "(&(sn=" + nom + ")(givenName=" + prenom + "))";
foreach (SearchResult result in searcher.FindAll())
{
Personne perso = new Personne();
DirectoryEntry DirEntry = result.GetDirectoryEntry();
perso.NomRes = (string)DirEntry.Properties["sn"].Value;
perso.PrenomRes = (string)DirEntry.Properties["givenName"].Value;
if ((string)DirEntry.Properties["telephoneNumber"].Value != null)
perso.TelRes = (string)DirEntry.Properties["telephoneNumber"].Value;
if ((string)DirEntry.Properties["mobiletelephonenumber"].Value != null)
perso.MobileRes = (string)DirEntry.Properties["mobiletelephonenumber"].Value;
}
_employes.Add(perso);
}
_employes.Sort();
Ldap.Close();
}
catch (Exception Ex)
{
return Ex.Message;
}
return "Erreur, veuillez contactez l'administrateur.";
}
} |
Partager