/// <summary>
        /// Takes in an Email and returns a LDAP Object(Person Object) of that User
        /// </summary>
        /// <param name="emailAlias"></param>
        /// <returns>LDAPuser</returns>
        public static LDAPuser getLDAPEntryByEmailAlias(string emailAlias)
        {
            // Split the email address and get the contents before the @
            string[] splitEmailAlias = emailAlias.Split('@');
            string   templeEduTUNA   = splitEmailAlias[0];

            // Create the WebService proxy, send the search request and receive the TempleLDAPEntry object
            WS_LDAPSearch.LDAP_Search       ldapProxy = new WS_LDAPSearch.LDAP_Search();
            WS_LDAPSearch.TempleLDAPEntry[] results   = new WS_LDAPSearch.TempleLDAPEntry[1];
            results = ldapProxy.Search(webServiceUsername, webServicePassword, "templeEduTUNA", templeEduTUNA);
            WS_LDAPSearch.TempleLDAPEntry resultEntry = results[0];

            // Check if request was successful
            if (resultEntry.error == null) // Success
            {
                // Create our TempleLDAPEntry object to be returned
                LDAPuser personLDAPEntry = new LDAPuser();
                personLDAPEntry.templeEduID                 = resultEntry.templeEduTUID;
                personLDAPEntry.uID                         = resultEntry.uid;
                personLDAPEntry.cn                          = resultEntry.cn;
                personLDAPEntry.givenName                   = resultEntry.givenName;
                personLDAPEntry.sn                          = resultEntry.sn;
                personLDAPEntry.eduPersonAffiliation        = resultEntry.eduPersonAffiliation;
                personLDAPEntry.eduPersonPrimaryAffiliation = resultEntry.eduPersonPrimaryAffiliation;
                personLDAPEntry.mail                        = resultEntry.mail;
                personLDAPEntry.title                       = resultEntry.title;
                return(personLDAPEntry);
            }
            else // Something went wrong..
            {
                return(null);
            }
        }
        /// <summary>
        /// Takes in an accessnet and returns an LDAPuser (Person Object) based on that AccessnetID
        /// </summary>
        /// <param name="accessnetID"></param>
        /// <returns>LDAPuser</returns>
        public static LDAPuser getLDAPEntryByAccessnet(string accessnetID)
        {
            // Create the WebService proxy, send the search request and receive the TempleLDAPEntry object
            WS_LDAPSearch.LDAP_Search       ldapProxy = new WS_LDAPSearch.LDAP_Search();
            WS_LDAPSearch.TempleLDAPEntry[] results   = new WS_LDAPSearch.TempleLDAPEntry[1];
            results = ldapProxy.Search(webServiceUsername, webServicePassword, "uid", accessnetID);
            WS_LDAPSearch.TempleLDAPEntry resultEntry = results[0];

            // Check if request was successful
            if (resultEntry.error == null) // Success
            {
                // Create our TempleLDAPEntry object to be returned
                LDAPuser personLDAPEntry = new LDAPuser();
                personLDAPEntry.templeEduID                 = resultEntry.templeEduTUID;
                personLDAPEntry.uID                         = resultEntry.uid;
                personLDAPEntry.cn                          = resultEntry.cn;
                personLDAPEntry.givenName                   = resultEntry.givenName;
                personLDAPEntry.sn                          = resultEntry.sn;
                personLDAPEntry.eduPersonAffiliation        = resultEntry.eduPersonAffiliation;
                personLDAPEntry.eduPersonPrimaryAffiliation = resultEntry.eduPersonPrimaryAffiliation;
                personLDAPEntry.mail                        = resultEntry.mail;
                personLDAPEntry.title                       = resultEntry.title;
                return(personLDAPEntry);
            }
            else // Something went wrong..
            {
                return(null);
            }
        }
Exemple #3
0
        protected void btnFindStudent_Click(object sender, EventArgs e)
        {
            string   tuID = findTUID.Text;
            LDAPuser user = new LDAPuser();

            user = Login.getLDAPEntryByTUID(tuID);

            if (user != null)
            {
                txtExportLastName.Text  = user.sn;
                txtExportFirstName.Text = user.givenName;
                txtExportTUID.Text      = user.templeEduID;
                txtExportUsername.Text  = user.uID;
                lblFoundID.Text         = "true";

                ClientScript.RegisterStartupScript(this.GetType(), "alert", "showExportPopup();", true);
                findTUID.Text = "";
            }
            else
            {
                lblFoundID.Text = "false";
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "showNotFoundPopup();", true);
                findTUID.Text = "";
            }
        }
        protected void btnFindUser_Click(object sender, EventArgs e)
        {
            string   accessnet = findAccessNetID.Text;
            LDAPuser user      = new LDAPuser();

            user = Login.getLDAPEntryByAccessnet(accessnet);

            if (user != null)
            {
                txtLastName.Text  = user.sn;
                txtFirstName.Text = user.givenName;
                txtTUID.Text      = user.templeEduID;
                txtUsername.Text  = user.uID;
                lblFoundID.Text   = "true";

                ClientScript.RegisterStartupScript(this.GetType(), "alert", "showAddAdminPopup();", true);
                findAccessNetID.Text = "";
            }
            else
            {
                lblFoundID.Text = "false";
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "showNotFoundPopup();", true);
                findAccessNetID.Text = "";
            }
        }
        /// <summary>
        /// Returns an array of all colleges
        /// </summary>
        /// <returns></returns>
        //public static College[] getAllColleges()
        //{
        //try
        //{
        //WS_ProgramsAndDegrees.ProgramsAndDegrees programsProxy = new WS_ProgramsAndDegrees.ProgramsAndDegrees();
        //WS_ProgramsAndDegrees.ProgramsAndDegreesEntry[] results = new WS_ProgramsAndDegrees.ProgramsAndDegreesEntry[30];
        //results = programsProxy.GetAllColleges(webServiceUsername, webServicePassword);

        //College[] colleges = new College[results.Length];

        //for (int i = 0; i < results.Length; i++)
        //{
        //College c = new College();
        //c.collegeName = results[i].college.ToString();
        //c.collegeCode = results[i].collegeCode.ToString();
        //colleges[i] = c;
        //}

        //return colleges;
        //}
        //catch (Exception ex)
        //{
        //return null;
        //}
        //}

        /// <summary>
        /// Takes in a College Code and returns a Name Identified by that Code
        /// </summary>
        /// <param name="collegeCode"></param>
        /// <returns></returns>
        //public static string getCollegeNameByCollegeCode(string collegeCode)
        //{
        //try
        //{
        //WS_ProgramsAndDegrees.ProgramsAndDegrees programsProxy = new WS_ProgramsAndDegrees.ProgramsAndDegrees();
        //WS_ProgramsAndDegrees.ProgramsAndDegreesEntry[] results = new WS_ProgramsAndDegrees.ProgramsAndDegreesEntry[30];
        //results = programsProxy.GetAllColleges(webServiceUsername, webServicePassword);

        //foreach (WS_ProgramsAndDegrees.ProgramsAndDegreesEntry entry in results)
        //{
        //if (entry.collegeCode.Equals(collegeCode))
        //{
        //return entry.college;
        //}
        //}
        //}
        //catch (Exception ex)
        //{
        //return null;
        //}

        //return null;
        //}

        /// <summary>
        /// takes in a TUID and creates a StudentObj with Full name, Email, TUID, Major, and College Code
        /// </summary>
        /// <param name="TUID"></param>
        /// <returns></returns>
        public static StudentObj getStudentInfo(string TUID)
        {
            //////// Get LDAP Info
            StudentObj student = new StudentObj();
            LDAPuser   entry   = getLDAPEntryByTUID(TUID);

            if (entry != null)
            {
                String[] name = entry.cn.Split(null); // splits 'cn' into first, middle, last

                if (name.Length == 2)                 // No middle initial
                {
                    student.firstName  = name[0];
                    student.middleInit = "";
                    student.lastName   = name[1];
                }
                else if (name.Length == 3) // Has middle initial
                {
                    student.firstName  = name[0];
                    student.middleInit = name[1];
                    student.lastName   = name[2];
                }
                else if (name.Length == 4) // Special case for people with 4 part names
                {
                    student.firstName  = name[0];
                    student.middleInit = name[1] + " " + name[2];
                    student.lastName   = name[3];
                }

                student.email = entry.mail;
                student.tuid  = entry.templeEduID;

                //////// Get Academic Info
                WS_StudentSearch.WS_Student studentProxy = new WS_StudentSearch.WS_Student();
                WS_StudentSearch.Result     results      = new WS_StudentSearch.Result();
                results = studentProxy.GetAcademicInfoByTUID(webServiceUsername, webServicePassword, TUID);

                // Check if request was successful
                if (results.Status == "OK") // Success
                {
                    WS_StudentSearch.Student[] s = results.Students;
                    student.major1 = s[0].major1;
                    student.major2 = s[0].major2;
                    student.school = s[0].collegeCode;
                }
                else // Something went wrong...
                {
                    return(null);
                }
            }

            return(student);
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtUsername.Text))
            {
                lblText.Text = "Error: username cannot be blank";
            }

            else if (String.IsNullOrEmpty(txtPassword.Text))
            {
                lblText.Text = "Error: password cannot be blank";
            }

            else
            {
                Boolean test = AuthenticateUser(txtUsername.Text, txtPassword.Text);
                if (test == false)
                {
                    lblText.Text = "Error: invalid username/password";
                }
                else
                {
                    StoredProcedure sp1 = new StoredProcedure();
                    if (sp1.AdminLogin(txtUsername.Text) == true)
                    {
                        if (sp1.getAdminStatus(txtUsername.Text) == "Active")
                        {
                            LDAPuser user = new LDAPuser();
                            user = getLDAPEntryByAccessnet(txtUsername.Text);


                            Session["UserName"]    = txtUsername.Text;                     //accessnet username
                            Session["AccessLevel"] = sp1.getAccessLevel(txtUsername.Text); //access level
                            Session["firstName"]   = user.givenName;                       //first name
                            Session["lastName"]    = user.sn;                              //last name
                            Session["tuid"]        = user.templeEduID;                     //tuid

                            Response.Redirect("AdvisorDashboard.aspx");
                        }
                        else
                        {
                            lblText.Text = "Error: Account deactivated";
                        }
                    }
                    else
                    {
                        lblText.Text = "Error: Not a registered user";
                    }
                }
            }
        }