protected void SetupPageControls() { var userAD = db.spz_GetUserInfoFromAD(user.ID).ToList(); foreach (var item in userAD) { lblName.Text = item.Name; lblEmail.Text = item.mail; lblPhone.Text = item.TelephoneNumber; hfEmail.Value = item.mail; } if (SiteID > 0) { var site = db.Sites.FirstOrDefault(p => p.site_id == SiteID); lblSiteNo.Text = site.site_no + " " + db.vSITEFILEs.FirstOrDefault(p => p.site_id == site.nwisweb_site_id).station_nm; tbSiteNo.Visible = false; lblOptional.Visible = false; hfSiteID.Value = SiteID.ToString(); } else { lblSiteNo.Visible = false; } lblReqTypesHeading.Visible = false; rrblRTReqTypes.Visible = false; rrblNWISReqTypes.Visible = false; rrblMANUReqTypes.Visible = false; rrblOtherReqTypes.Visible = false; }
protected void rgPersonnel_ItemCommand(object sender, GridCommandEventArgs e) { GridEditableItem item = e.Item as GridEditableItem; if (e.CommandName == "ValidateUser") { Panel pnlInsert1 = (Panel)item.FindControl("pnlInsert1"); Panel pnlInsert2 = (Panel)item.FindControl("pnlInsert2"); RadTextBox rtbUserID2 = (RadTextBox)item.FindControl("rtbUserID2"); RadTextBox rtbFirstNm = (RadTextBox)item.FindControl("rtbFirstNm2"); RadTextBox rtbLastNm = (RadTextBox)item.FindControl("rtbLastNm2"); RadTextBox rtbUserID3 = (RadTextBox)item.FindControl("rtbUserID3"); var currUser = db.Employees.FirstOrDefault(p => p.user_id == rtbUserID2.Text); if (currUser != null) { DisplayMessage(true, "This user is already in the SIMS database. If the user you are trying to add is moving from a different WSC, their PrimaryOU information in Active Directory must first be changed. Then, an email should be sent to GS-W Help SIMS for help with adding them to your WSC's personnel list."); pnlInsert1.Visible = true; pnlInsert2.Visible = false; rtbUserID2.Text = ""; } else { var ADuser = db.spz_GetUserInfoFromAD(rtbUserID2.Text).Select(p => new Data.ADUserInfo { primaryOU = p.primaryOU, SN = p.SN, givenName = p.givenName }).FirstOrDefault(); if (ADuser != null) { var currUserWSC = db.spz_GetUserWSCID(ADuser.primaryOU).FirstOrDefault(); if (currUserWSC.wsc_id != WSCID) { DisplayMessage(true, "This user belongs to another WSC. Please contact GS-W Help [email protected] for assistance."); pnlInsert1.Visible = true; pnlInsert2.Visible = false; rtbUserID2.Text = ""; } else { rtbFirstNm.Text = ADuser.givenName; rtbLastNm.Text = ADuser.SN; rtbUserID3.Text = rtbUserID2.Text; pnlInsert1.Visible = false; pnlInsert2.Visible = true; } } else { DisplayMessage(true, "This user is not authorized. Please confirm that you are entering the user's Active Directory user ID, and not their email alias."); pnlInsert1.Visible = true; pnlInsert2.Visible = false; rtbUserID2.Text = ""; } } } }
private string EmailAddress(string user_id) { //If possible, get the email address for the user from AD string email = user_id + "@usgs.gov"; var reg_user = db.spz_GetUserInfoFromAD(user_id).ToList(); foreach (var result in reg_user) { email = result.mail; } return(email); }
public WindowsAuthenticationUser() { //DB Connection Data.SIMSDataContext db = new Data.SIMSDataContext(); //Grab the User ID from windows authentication _id = HttpContext.Current.User.Identity.Name.Replace("-pr", ""); int pos = _id.IndexOf("\\"); _id = _id.Substring(pos + 1); //try to see if the user is in the database var user = db.Employees.FirstOrDefault(p => p.user_id == _id); //If the user isn't null it has Admin priveldges, or doesn't if (user != null) { if (user.administrator_va == "SuperUser") { _superUser = true; } if (user.administrator_va == "WSC") { _admin = true; } if ((bool)user.approver_va) { _safetyapprover = true; } if (user.pass_access == "WSC") { _passadmin = true; } if (user.pass_access == "SuperUser") { _passsuperuser = true; } _firstName = user.first_nm; _lastName = user.last_nm; _office_id = (int)user.office_id; _wsc_id.Add((int)user.Office.wsc_id); _active = (bool)user.active; _showreports = (bool)user.show_reports; _email = _id + "@usgs.gov"; //If possible, get the email address for the user from AD var reg_user = db.spz_GetUserInfoFromAD(_id).ToList(); foreach (var result in reg_user) { _email = result.mail; _primaryOU = result.primaryOU; } //Add WSCs for which the user has exceptions foreach (int wsc in user.Exceptions.Select(p => p.exc_wsc_id).ToList()) { _wsc_id.Add(wsc); } //Add WSCs for which the WSC of the user has exceptions foreach (int wsc in db.ExceptionWSCs.Where(p => p.AD_OU == _primaryOU).Select(p => p.exc_wsc_id).ToList()) { _wsc_id.Add(wsc); } } else { try { var unreg_user = db.spz_GetUserInfoFromAD(_id).ToList(); string primaryOU = "AustinTX-W"; string email = _id + "@usgs.gov"; foreach (var result in unreg_user) { primaryOU = result.primaryOU; email = result.mail; } var wsc = db.WSCs.FirstOrDefault(p => p.AD_OU.Contains(primaryOU)); var office = db.Offices.FirstOrDefault(p => p.wsc_id == wsc.wsc_id); _office_id = office.office_id; _wsc_id.Add(wsc.wsc_id); _email = email; _active = false; _showreports = false; //Add WSCs for which the WSC of the user has exceptions foreach (int w in db.ExceptionWSCs.Where(p => p.AD_OU == primaryOU).Select(p => p.exc_wsc_id).ToList()) { _wsc_id.Add(w); } } catch (Exception ex) { _office_id = 348; _wsc_id.Add(31); _email = "*****@*****.**"; _active = false; _showreports = false; } } }