|
@@ -14,20 +14,73 @@ using System.Xml;
|
|
|
using CG67.FicheCollege.Service;
|
|
using CG67.FicheCollege.Service;
|
|
|
using CG67.FicheCollege.Domaine;
|
|
using CG67.FicheCollege.Domaine;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
|
+using System.DirectoryServices;
|
|
|
|
|
+using System.Linq;
|
|
|
|
|
+//using System.DirectoryServices.AccountManagement;
|
|
|
|
|
|
|
|
namespace CG67.FicheCollege
|
|
namespace CG67.FicheCollege
|
|
|
{
|
|
{
|
|
|
public partial class FicheCollege : System.Web.UI.Page
|
|
public partial class FicheCollege : System.Web.UI.Page
|
|
|
{
|
|
{
|
|
|
|
|
+ public string user;
|
|
|
|
|
+
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
{
|
|
{
|
|
|
//Intialisation des paramètres
|
|
//Intialisation des paramètres
|
|
|
//l'année en cours est déclarée dans le fichier de configuration
|
|
//l'année en cours est déclarée dans le fichier de configuration
|
|
|
int annee = int.Parse(ConfigurationManager.AppSettings["AnneeEnCours"]);
|
|
int annee = int.Parse(ConfigurationManager.AppSettings["AnneeEnCours"]);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
HttpContext.Current.Session["Annee"] = annee;
|
|
HttpContext.Current.Session["Annee"] = annee;
|
|
|
HttpContext.Current.Session["AnneeMoins1"] = annee - 1;
|
|
HttpContext.Current.Session["AnneeMoins1"] = annee - 1;
|
|
|
|
|
+
|
|
|
HttpContext.Current.Session["RNE"] = Request["RNE"];
|
|
HttpContext.Current.Session["RNE"] = Request["RNE"];
|
|
|
|
|
+
|
|
|
|
|
+ string domain = "DC=cg67,DC=fr";
|
|
|
|
|
+
|
|
|
|
|
+ string sUser = ConfigurationManager.AppSettings["USER-LDAP"];
|
|
|
|
|
+
|
|
|
|
|
+ string sMdp = ConfigurationManager.AppSettings["MDP-LDAP"];
|
|
|
|
|
+
|
|
|
|
|
+ using (var rootEntry = new DirectoryEntry("LDAP://CG67/" + domain, null, null, AuthenticationTypes.Secure))
|
|
|
|
|
+ {
|
|
|
|
|
+ // using (var directorySearcher = new DirectorySearcher(rootEntry, String.Format("(sAMAccountName={0})", HttpContext.Current.User.Identity.Name.Replace("CG67\\",""))))
|
|
|
|
|
+ using (var directorySearcher = new DirectorySearcher(rootEntry, String.Format("(sAMAccountName={0})", "frederic.bierry")))
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ var searchResult = directorySearcher.FindOne();
|
|
|
|
|
+ if (searchResult != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ using (var userEntry = searchResult.GetDirectoryEntry())
|
|
|
|
|
+ {
|
|
|
|
|
+ string cnUser = userEntry.Properties["distinguishedName"].Value.ToString();
|
|
|
|
|
+
|
|
|
|
|
+ List<string> Groups = new List<string>();
|
|
|
|
|
+ Groups = cnUser.Split(new[] {"," } , StringSplitOptions.None).ToList();
|
|
|
|
|
+
|
|
|
|
|
+ Response.Write(cnUser);
|
|
|
|
|
+
|
|
|
|
|
+ var elu = Groups.Where(x => x.Contains("OU=P2-ELUS")).FirstOrDefault();
|
|
|
|
|
+
|
|
|
|
|
+ if (!string.IsNullOrEmpty(elu)) user= elu.Replace("OU=","");
|
|
|
|
|
+
|
|
|
|
|
+ var mission = Groups.Where(x => x.Contains("OU=E-")).FirstOrDefault();
|
|
|
|
|
+
|
|
|
|
|
+ if (!string.IsNullOrEmpty(mission)) user = mission.Replace("OU=","");
|
|
|
|
|
+
|
|
|
|
|
+ //cas autre a faire
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
//Traitement
|
|
//Traitement
|
|
|
XmlDocument entete = new XmlDocument();
|
|
XmlDocument entete = new XmlDocument();
|