|
@@ -16,6 +16,7 @@ using CG67.FicheCollege.Domaine;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
using System.DirectoryServices;
|
|
using System.DirectoryServices;
|
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
|
+using System.Text.RegularExpressions;
|
|
|
//using System.DirectoryServices.AccountManagement;
|
|
//using System.DirectoryServices.AccountManagement;
|
|
|
|
|
|
|
|
namespace CG67.FicheCollege
|
|
namespace CG67.FicheCollege
|
|
@@ -30,24 +31,21 @@ namespace CG67.FicheCollege
|
|
|
//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 domain = "DC=cg67,DC=fr";
|
|
|
|
|
|
|
|
- string sUser = ConfigurationManager.AppSettings["USER-LDAP"];
|
|
|
|
|
|
|
+ //string sUser = ConfigurationManager.AppSettings["USER-LDAP"];
|
|
|
|
|
|
|
|
- string sMdp = ConfigurationManager.AppSettings["MDP-LDAP"];
|
|
|
|
|
|
|
+ //string sMdp = ConfigurationManager.AppSettings["MDP-LDAP"];
|
|
|
|
|
|
|
|
using (var rootEntry = new DirectoryEntry("LDAP://CG67/" + domain, null, null, AuthenticationTypes.Secure))
|
|
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")))
|
|
|
|
|
-
|
|
|
|
|
|
|
+ using (var directorySearcher = new DirectorySearcher(rootEntry, String.Format("(sAMAccountName={0})", HttpContext.Current.User.Identity.Name.Replace("CG67\\",""))))
|
|
|
{
|
|
{
|
|
|
var searchResult = directorySearcher.FindOne();
|
|
var searchResult = directorySearcher.FindOne();
|
|
|
if (searchResult != null)
|
|
if (searchResult != null)
|
|
@@ -57,49 +55,51 @@ namespace CG67.FicheCollege
|
|
|
string cnUser = userEntry.Properties["distinguishedName"].Value.ToString();
|
|
string cnUser = userEntry.Properties["distinguishedName"].Value.ToString();
|
|
|
|
|
|
|
|
List<string> Groups = new List<string>();
|
|
List<string> Groups = new List<string>();
|
|
|
- Groups = cnUser.Split(new[] {"," } , StringSplitOptions.None).ToList();
|
|
|
|
|
|
|
|
|
|
- Response.Write(cnUser);
|
|
|
|
|
|
|
+ Groups = cnUser.Split(new[] {"," } , StringSplitOptions.None).ToList();
|
|
|
|
|
|
|
|
- var elu = Groups.Where(x => x.Contains("OU=P2-ELUS")).FirstOrDefault();
|
|
|
|
|
|
|
+ var rx = new Regex("OU=[AEFGHIJKLMP]{1}\\-[A-Z]{3,5}", RegexOptions.IgnoreCase);
|
|
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(elu)) user= elu.Replace("OU=","");
|
|
|
|
|
|
|
+ user = "AUTRE";
|
|
|
|
|
|
|
|
- var mission = Groups.Where(x => x.Contains("OU=E-")).FirstOrDefault();
|
|
|
|
|
|
|
+ var mission = Groups.Where(x => rx.IsMatch(x)).FirstOrDefault();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(mission)) user = mission.Replace("OU=","");
|
|
if (!string.IsNullOrEmpty(mission)) user = mission.Replace("OU=","");
|
|
|
|
|
|
|
|
- //cas autre a faire
|
|
|
|
|
|
|
+ if (user == "P-CAB")
|
|
|
|
|
+ {
|
|
|
|
|
+ var elu = Groups.Where(x => x.Contains("OU=P2-ELUS")).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(elu)) user = elu.Replace("OU=", "");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
//Traitement
|
|
//Traitement
|
|
|
XmlDocument entete = new XmlDocument();
|
|
XmlDocument entete = new XmlDocument();
|
|
|
entete.Load(Server.MapPath(@"~/xml/entete.xml"));
|
|
entete.Load(Server.MapPath(@"~/xml/entete.xml"));
|
|
|
|
|
|
|
|
- XmlNode xmlFicheCollege = ServiceFiche.GetFicheCollege(Session["RNE"].ToString(), int.Parse(Session["annee"].ToString()));
|
|
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ //modif car si code rne null provoque une erreur
|
|
|
|
|
+
|
|
|
|
|
+ XmlNode xmlFicheCollege = ServiceFiche.GetFicheCollege(Session["RNE"].ToString(), int.Parse(Session["annee"].ToString()));
|
|
|
|
|
|
|
|
- this.Title = xmlFicheCollege.SelectSingleNode("college/Etablissement/NomCollegePourPresentation").InnerText;
|
|
|
|
|
- xmlFicheCollege.SelectSingleNode("college").InnerXml += entete.DocumentElement.OuterXml;
|
|
|
|
|
|
|
+ this.Title = xmlFicheCollege.SelectSingleNode("college/Etablissement/NomCollegePourPresentation").InnerText;
|
|
|
|
|
+ xmlFicheCollege.SelectSingleNode("college").InnerXml += entete.DocumentElement.OuterXml;
|
|
|
|
|
|
|
|
- this.Xml1.DocumentContent = xmlFicheCollege.OuterXml;
|
|
|
|
|
|
|
+ this.Xml1.DocumentContent = xmlFicheCollege.OuterXml;
|
|
|
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
this.DataBind();
|
|
this.DataBind();
|
|
|
}
|
|
}
|
|
|
catch (NullReferenceException nre)
|
|
catch (NullReferenceException nre)
|
|
|
{
|
|
{
|
|
|
Console.WriteLine("Erreur de pointeur : null", nre.Message);
|
|
Console.WriteLine("Erreur de pointeur : null", nre.Message);
|
|
|
|
|
+ //Response.Redirect("/");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|