protected void EditForm_DataBound(object sender, EventArgs e) { string timeZoneId = null; string timeFormat = null; string dateFormat = null; if (EditForm.DataItem != null) { ClientDataSet.UserRow row = (ClientDataSet.UserRow)EditForm.DataItem; if (!row.IsTimeZoneIdNull()) { timeZoneId = row.TimeZoneId; } if (!row.IsTimeFormatNull()) { timeFormat = row.TimeFormat.ToString(CultureInfo.InvariantCulture); } if (!row.IsDateFormatNull()) { dateFormat = row.DateFormat.ToString(CultureInfo.InvariantCulture); } } BaseControl.TimeZoneListDataBind(TimeZoneList, timeZoneId, false); BaseControl.TimeFormatListDataBind(TimeFormatList, timeFormat, false); BaseControl.DateFormatListDataBind(DateFormatList, dateFormat, false); TokenControl token = (TokenControl)EditForm.FindControl("Token"); token.LoginId = UserContext.Current.UserId; }
private int ValidateLoginName(string loginName) { int returnValue = 0; ConfirmPasswordRow.Visible = true; if (LoginProvider.Current.LoginNameExists(loginName)) { if (LoginProvider.Current.LoginInOrganization(loginName, this.OrganizationId)) { this.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, Resources.SignupUserControl_ErrorMessage_LoginInOrganizationExists, m_Organization.Name)); return(1); } ClientDataSet.UserRow userRow = UserProvider.GetUserRow(loginName); if (userRow != null) { FirstNameTextBox.Text = userRow.FirstName; LastNameTextBox.Text = userRow.LastName; } ConfirmPasswordRow.Visible = false; this.ShowDescription(string.Format(CultureInfo.CurrentCulture , Resources.SignupUserControl_DescriptionLabel_Text_UserExists , string.Concat(CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.PasswordRecoveryPageVirtualPath), "?l=", HttpUtility.UrlEncode(loginName)))); returnValue = 2; } LoginTextLabel.Text = loginName; FirstNameTextBox.Focus(); Step1Table.Visible = false; Step2Table.Visible = true; if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern) { MainContainer.Style[HtmlTextWriterStyle.Height] = "500px"; MainContainer.Style[HtmlTextWriterStyle.MarginTop] = "-250px"; } else { MainContainer.Style[HtmlTextWriterStyle.Height] = "360px"; MainContainer.Style[HtmlTextWriterStyle.MarginTop] = "-180px"; } return(returnValue); }
protected void EditForm_DataBound(object sender, EventArgs e) { if (EditForm.CurrentMode == DetailsViewMode.Insert) { if (!UserChecked) { EditForm.Rows[14].Visible = false; } } string timeZoneId = null; string timeFormat = null; string dateFormat = null; if (EditForm.DataItem != null) { ClientDataSet.UserRow row = (ClientDataSet.UserRow)EditForm.DataItem; if (!row.IsTimeZoneIdNull()) { timeZoneId = row.TimeZoneId; } if (!row.IsTimeFormatNull()) { timeFormat = row.TimeFormat.ToString(CultureInfo.InvariantCulture); } if (!row.IsDateFormatNull()) { dateFormat = row.DateFormat.ToString(CultureInfo.InvariantCulture); } TokenControl token = (TokenControl)EditForm.FindControl("Token"); token.LoginId = row.UserId; } BaseControl.TimeZoneListDataBind(TimeZoneList, timeZoneId, false); BaseControl.TimeFormatListDataBind(TimeFormatList, timeFormat, false); BaseControl.DateFormatListDataBind(DateFormatList, dateFormat, false); }
private static void LocalUsersCheckGroups(Guid organizationId, DataTable localMappedLogins, DomainUserCollection users, MasterDataSet.OrganizationsLdapGroupsDataTable orgTable, MasterDataSet.GroupMappingsDataTable groupMappings) { DataView ldapGroups = null; ClientDataSet.UserRow userRow = null; StringBuilder newUserGroups = null; User ldapUser = null; DomainUser ldapDomainUser = null; LoginProvider provider = null; String groupId = null; Guid ldapUserId = Guid.Empty; StringBuilder sb = null; String email = null; try { for (int i = 0; i < users.Count; i++) { ldapDomainUser = users[i]; sb = new StringBuilder(); sb.Append("("); sb.AppendFormat("(LdapUserId='{0}') ", ldapDomainUser.ObjectGuid); if (!string.IsNullOrEmpty(ldapDomainUser.PrincipalName)) { sb.AppendFormat(" OR (LoginName = '{0}')", ldapDomainUser.PrincipalName.Replace("'", "''")); } else { ldapDomainUser.PrincipalName = string.Empty; } if (!string.IsNullOrEmpty(ldapDomainUser.EmailAddress)) { sb.AppendFormat(" OR (LoginName = '{0}')", ldapDomainUser.EmailAddress.Replace("'", "''")); } else { ldapDomainUser.EmailAddress = string.Empty; } sb.Append(")"); foreach (DataRow dr in localMappedLogins.Select(sb.ToString())) { try { newUserGroups = new StringBuilder(string.Empty); try { ldapUserId = (Guid)dr["LdapUserId"]; } catch { ldapUserId = Guid.Empty; } if (ldapDomainUser.ObjectGuid == ldapUserId || ldapDomainUser.PrincipalName.ToLower(CultureInfo.InvariantCulture) == ((string)dr["LoginName"]).ToLower(CultureInfo.InvariantCulture) || (ldapDomainUser.EmailAddress != null && ldapDomainUser.EmailAddress.ToLower(CultureInfo.InvariantCulture) == ((string)dr["LoginName"]).ToLower(CultureInfo.InvariantCulture))) { foreach (string groupDN in ldapDomainUser.MemberOfGroups) { for (int j = 0; j < orgTable.Rows.Count; j++) { if (groupDN == orgTable.Rows[j]["DistinguishedName"].ToString()) { for (int k = 0; k < groupMappings.Rows.Count; k++) { if ((Guid)orgTable.Rows[j]["ObjectGUID"] == (Guid)groupMappings.Rows[k]["LdapGroupId"]) { if (!string.Concat(",", newUserGroups.ToString(), ",").Contains(string.Concat(",", (Guid)groupMappings.Rows[k]["GroupId"], ","))) { newUserGroups.AppendFormat(",{0}", (Guid)groupMappings.Rows[k]["GroupId"]); } } } } } } userRow = UserProvider.GetUserRow((Guid)dr["LoginId"], organizationId, true); if (userRow == null) { continue; } UserProvider.UpdateUser((Guid)dr["LoginId"], newUserGroups.ToString(), organizationId, false); // Check user email ldapUser = (User)LdapInfoProvider.GetLdapUser(organizationId, ldapDomainUser); if (ldapUser != null) { LoginProvider.Current.UpdateUserLdapInfo(organizationId, (Guid)dr["LoginId"], ldapUser.FirstName, ldapUser.LastName, ldapUser.LdapDomain, ldapUser.LdapDomainFull, ldapUser.LdapUserAlias, ldapUser.LdapUserPrinciple, ldapUser.UserSid, ldapUser.UserId, ldapUser.LdapOUPath); if (string.IsNullOrEmpty(ldapUser.EmailAddress) == false && string.Compare(userRow.Email, ldapUser.EmailAddress, StringComparison.CurrentCultureIgnoreCase) != 0) { provider = new LoginProvider(); if (!provider.LoginNameExists(ldapUser.EmailAddress)) { email = userRow.Email; UserProvider.UpdateUser(userRow.UserId, ldapUser.EmailAddress, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, groupId, organizationId, false); } if (provider != null) { provider = null; } } } UserProvider.RaiseUserUpdated(userRow.UserId, organizationId, Bll.Support.ConvertStringToGuidList(newUserGroups.ToString()), email); break; } } catch (Exception ex) { LdapInfoProvider.InsertLdapLog(organizationId, true, string.Format(CultureInfo.InvariantCulture, "<br/>{0}", ex.ToString().Replace("\r\n", "<br/>"))); } } } } finally { if (ldapGroups != null) { ldapGroups.Dispose(); } if (newUserGroups != null) { newUserGroups.Remove(0, newUserGroups.Length); newUserGroups = null; } if (sb != null) { sb.Remove(0, sb.Length); sb = null; } ldapUser = null; userRow = null; provider = null; groupId = null; email = null; } }
protected void EditForm_ItemInserting(object sender, DetailsViewInsertEventArgs e) { if (e == null) { return; } if (!UserChecked) { e.Cancel = true; string loginName = e.Values["Email"].ToString(); string firstName = string.Empty; string middleName = string.Empty; string lastName = string.Empty; if (LoginProvider.Current.LoginNameExists(loginName)) { if (LoginProvider.Current.LoginInOrganization(loginName, m_UserContext.OrganizationId)) { ErrorPanel.InnerHtml = Resources.UsersControl_ErrorMessage_UserInOrganizationExists; ErrorPanel.Visible = true; return; } ClientDataSet.UserRow userRow = UserProvider.GetUserRow(loginName); if (userRow != null) { firstName = userRow.FirstName; middleName = userRow.MiddleName; lastName = userRow.LastName; } } TextBoxField field = (EditForm.Fields[0] as TextBoxField); if (field != null) { field.DefaultText = loginName; field.ReadOnly = true; } field = (EditForm.Fields[1] as TextBoxField); if (field != null) { field.DefaultText = firstName; } field = (EditForm.Fields[2] as TextBoxField); if (field != null) { field.DefaultText = middleName; } field = (EditForm.Fields[3] as TextBoxField); if (field != null) { field.DefaultText = lastName; } UserChecked = true; EditForm_ShowDetails(true); } }
private void MessageRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (!((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))) { return; } this.MessagesCount = this.MessagesCount + 1; DataRowView drv = e.Item.DataItem as DataRowView; if (drv == null) { return; } ClientDataSet.MessageRow messageRow = drv.Row as ClientDataSet.MessageRow; if (messageRow == null) { return; } if (e.Item.ItemIndex == 0) { this.ParentMessageId = messageRow.MessageId; } Panel subjectPanel = null; Literal subjectLiteral = null; Panel headerPanel = null; Panel textPanel = null; Literal textLiteral = null; try { if (!string.IsNullOrEmpty(messageRow.Subject)) { subjectPanel = new Panel(); subjectPanel.ApplyStyle(this.SubjectStyle); subjectPanel.Width = Unit.Percentage(100); e.Item.Controls.Add(subjectPanel); subjectLiteral = new Literal(); subjectLiteral.Text = messageRow.Subject; subjectPanel.Controls.Add(subjectLiteral); } headerPanel = new Panel(); headerPanel.ApplyStyle(this.HeaderStyle); headerPanel.HorizontalAlign = HorizontalAlign.Right; headerPanel.Width = Unit.Percentage(100); e.Item.Controls.Add(headerPanel); string headerText = string.Empty; ClientDataSet.UserRow userRow = UserProvider.GetUserRow(messageRow.FromUserId, false); if (userRow != null) { headerText = userRow.FullName; } if (!messageRow.IsToUserIdNull()) { userRow = UserProvider.GetUserRow(messageRow.ToUserId, false); if (userRow != null) { if (!string.IsNullOrEmpty(headerText)) { headerText += Resources.MessageList_FromToSeparator; } headerText += userRow.FullName; } } string createdTimeText = string.Format(this.Culture, this.DateTimeFormatString, messageRow.CreatedTime.AddHours(this.DateTimeHoursOffset)); if (!string.IsNullOrEmpty(headerText)) { headerText = "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"text-align: left;\">" + headerText + "</td><td style=\"text-align: right;\">" + createdTimeText + "</tr></table>"; } else { headerText = createdTimeText; } headerPanel.Controls.Add(new LiteralControl(headerText)); if (!string.IsNullOrEmpty(messageRow.Text)) { textPanel = new Panel(); textPanel.Width = Unit.Percentage(100); textPanel.ApplyStyle(this.TextStyle); e.Item.Controls.Add(textPanel); textLiteral = new Literal(); textPanel.Controls.Add(textLiteral); textLiteral.Text = messageRow.Text; } } finally { if (subjectPanel != null) { subjectPanel.Dispose(); } if (subjectLiteral != null) { subjectLiteral.Dispose(); } if (headerPanel != null) { headerPanel.Dispose(); } if (textPanel != null) { textPanel.Dispose(); } if (textLiteral != null) { textLiteral.Dispose(); } } }