/// <summary> /// Event handler that gets called when the Add DataPath button is clicked. /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void OnAddDataPathButton_Click(object source, EventArgs e) { if (!ValidPage) { TopNav.ShowError(GetString("ALLFIELDSREQUIRED")); } else { iFolderServer server = web.GetServer(ServerID); remoteweb.PreAuthenticate = true; remoteweb.Credentials = web.Credentials; remoteweb.Url = server.PublicUrl + "/iFolderAdmin.asmx"; int result = remoteweb.AddDataStore(DataPathName.Text, FullPath.Text, ServerID); switch (result) { case 0: string url = web.TrimUrl(ReferringPage); Page.Response.Redirect(url, true); break; case 1: TopNav.ShowError(GetString("LINKALREADYEXISTS")); break; case 2: TopNav.ShowError(GetString("INVALIDFULLPATH")); break; } } }
/// <summary> /// Page_PreRender /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_PreRender(object sender, EventArgs e) { string unAuthMessage = Request.QueryString.Get("Msg"); if (unAuthMessage != null) { DisplayErrorMessage.Text = unAuthMessage; DisplayErrorMessage.Visible = true; StackDump.Visible = false; } // message from query string string message = Request.QueryString.Get("ex"); if ((message == null) || (message.Length < 0)) { Exception ex = Session["Exception"] as Exception; if (ex != null) { TopNav.ShowError(ex); if (TopNav.ShowExceptionDetail(ex)) { StringWriter sw = new StringWriter(); sw.WriteLine("Server Version: {0}", Session["Version"]); sw.WriteLine("HostName: {0}", Session["HostName"]); sw.WriteLine("MachineName: {0}", Session["MachineName"]); sw.WriteLine("OS Version: {0}", Session["OSVersion"]); sw.WriteLine("CLR Version: {0}", Session["ClrVersion"]); sw.WriteLine(); sw.WriteLine(); sw.WriteLine("Exception detail:"); sw.WriteLine(); sw.WriteLine("Exception type: {0}", TopNavigation.GetExceptionType(ex)); sw.WriteLine(); sw.WriteLine(ex.Message); sw.WriteLine(); sw.WriteLine(ex.StackTrace); StackDump.Text = sw.ToString(); } else { ExceptionNav.Visible = false; } } else { TopNav.ShowError(GetString("UNKNOWNERROR")); } } else { TopNav.ShowError(message); } }
/// <summary> /// Sets the ifolder synchronization status on all selected ifolders. /// </summary> /// <param name="syncStatus">If true then all selected ifolders will be enabled.</param> private void SetSelectediFolderStatus(bool syncStatus) { foreach (string ifolderID in CheckediFolders.Keys) { /// Check for rights... int preference = GetRightsForiFolder(ifolderID); if (preference == -1) { preference = 0xffff; } UserGroupAdminRights rights = new UserGroupAdminRights((int)preference); if (!rights.EnableDisableiFolderAllowed) { continue; } // Don't set the status if already set. if (CheckediFolders[ifolderID] as string != syncStatus.ToString()) { iFolderPolicy policy = Utils.GetiFolderPolicyObject(ifolderID); policy.Locked = syncStatus; string ifolderLocation = web.GetiFolderLocation(ifolderID); UriBuilder remoteurl = new UriBuilder(ifolderLocation); remoteurl.Path = (new Uri(web.Url)).PathAndQuery; web.Url = remoteurl.Uri.ToString(); try { web.SetiFolderPolicy(policy); } catch (Exception ex) { TopNav.ShowError(GetString("ERRORCANNOTSETIFOLDERSTATUS"), ex); web.Url = currentServerURL; return; } } } // Clear the checked members. CheckediFolders.Clear(); AlliFoldersCheckBox.Checked = false; // Set the action buttons. SetActionButtons(); web.Url = currentServerURL; // Rebind the data source with the new data. GetiFolders(); }
/// <summary> /// Displays an error message on the parent page. /// </summary> /// <param name="errMsg"></param> private void ShowError(string errMsg) { TopNavigation nav = Page.FindControl("TopNav") as TopNavigation; if (nav != null) { nav.ShowError(errMsg); } }
/// <summary> /// Sets the enabled status on all selected users. /// </summary> /// <param name="status">If true then all selected users will be enabled.</param> private void SetSelectedUserStatus(bool status) { foreach (string userID in CheckedUsers.Keys) { // Don't set the status if already set. if (( bool )CheckedUsers[userID] != status) { /// Check for the policy for the groupadmin... int preference = GetRightsForUser(userID); if (preference != -1 && preference != 0xffff) { UserGroupAdminRights rights = new UserGroupAdminRights((int)preference); if (rights.EnableDisableUserAllowed == false) { continue; } } UserPolicy policy = Utils.GetUserPolicyObject(userID); policy.LoginEnabled = status; try { web.SetUserPolicy(policy); } catch (Exception ex) { string errMsg = String.Format(GetString("ERRORCANNOTSETUSERPOLICY"), userID); TopNav.ShowError(errMsg, ex); return; } } } // Clear the checked members. CheckedUsers.Clear(); AllUsersCheckBox.Checked = false; // Set the action buttons. SetActionButtons(); // Rebind the data source with the new data. GetUsers(); }
/// <summary> /// Event handler that gets called when the create button is clicked. /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void OnCreateButton_Click(object source, EventArgs e) { if (!ValidPage) { TopNav.ShowError(GetString("ALLFIELDSREQUIRED")); } else { // Verify that the retyped password matches. if (Password.Text == RetypedPassword.Text) { try { web.CreateUser( UserName.Text, Password.Text, Guid.NewGuid().ToString(), FirstName.Text, LastName.Text, FullName.Text, String.Empty, String.Empty); // Return back to the referring page. string url = web.TrimUrl(ReferringPage); Page.Response.Redirect(url, true); } catch (Exception ex) { TopNav.ShowError(GetString("ERRORCANNOTCREATEUSER"), ex); } } else { TopNav.ShowError(GetString("PASSWORDSDONOTMATCH")); } } }
/// <summary> /// Event handler that gets called when the delete button is clicked. /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void OnDeleteClicked(object source, EventArgs e) { LinkButton lb = source as LinkButton; DataGridItem item = lb.Parent.Parent as DataGridItem; string userID = item.Cells[AccountsIDColumn].Text; iFolderUser user = web.GetUser(userID); bool deleted = false; iFolderServer[] iFolderServers = web.GetServers(); foreach (iFolderServer server in iFolderServers) { if (server.IsMaster) { UriBuilder remoteurl = new UriBuilder(server.PublicUrl); remoteurl.Path = (new Uri(web.Url)).PathAndQuery; web.Url = remoteurl.Uri.ToString(); try { deleted = web.DeleteFromUserMoveQueue(user.ID); if (deleted == true) { lb.Text = GetString("DELETED"); lb.Enabled = false; } } catch (Exception ex) { TopNav.ShowError(ex.Message); web.Url = currentServerURL; return; } } } web.Url = currentServerURL; }
/// <summary> /// Creates a list of iFolders where the user is a member. /// </summary> /// <returns>A DataView object containing the iFolder list.</returns> private DataView CreateiFolderList() { if (ErrorMsg != null) { TopNav.ShowError(ErrorMsg); } DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add(new DataColumn("VisibleField", typeof(bool))); dt.Columns.Add(new DataColumn("IDField", typeof(string))); dt.Columns.Add(new DataColumn("OwnerIDField", typeof(string))); dt.Columns.Add(new DataColumn("SharedField", typeof(bool))); dt.Columns.Add(new DataColumn("DisabledField", typeof(bool))); dt.Columns.Add(new DataColumn("EncryptedField", typeof(bool))); dt.Columns.Add(new DataColumn("NameField", typeof(string))); dt.Columns.Add(new DataColumn("OwnerNameField", typeof(string))); dt.Columns.Add(new DataColumn("ReachableField", typeof(bool))); dt.Columns.Add(new DataColumn("FullNameField", typeof(string))); dt.Columns.Add(new DataColumn("PreferenceField", typeof(int))); // Get the iFolder list for this user. iFolderSet list; switch (ActiveiFolderTab) { case ListDisplayType.Owned: list = web.GetiFoldersByMember(UserID, MemberRole.Owner, CurrentiFolderOffset, iFolderList.PageSize); break; case ListDisplayType.Shared: list = web.GetiFoldersByMember(UserID, MemberRole.Shared, CurrentiFolderOffset, iFolderList.PageSize); break; case ListDisplayType.All: default: list = web.GetiFoldersByMember(UserID, MemberRole.Any, CurrentiFolderOffset, iFolderList.PageSize); break; } iFolder ifolder = null; foreach (iFolder folder in list.Items) { bool encrypted = false; try { string ifolderLocation = web.GetiFolderLocation(folder.ID); UriBuilder remoteurl = new UriBuilder(ifolderLocation); remoteurl.Path = (new Uri(web.Url)).PathAndQuery; web.Url = remoteurl.Uri.ToString(); } catch { //skip exceptions continue; } try { ifolder = web.GetiFolder(folder.ID); } catch { web.Url = currentServerURL; ifolder = web.GetiFolder(folder.ID); reachable = false; } string EncryptionAlgorithm = ifolder.EncryptionAlgorithm; if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty))) { // It is an encrypted ifolder encrypted = true; } string ShortenedName = null; int ShortenedLength = 40; if (folder.Name.Length > ShortenedLength) { // make it of desired length ShortenedName = web.GetShortenedName(folder.Name, ShortenedLength); } dr = dt.NewRow(); dr[0] = true; dr[1] = folder.ID; dr[2] = folder.OwnerID; dr[3] = (folder.MemberCount > 1) ? true : false; dr[4] = !ifolder.Enabled; dr[5] = (encrypted) ? true : false; dr[6] = (folder.Name.Length > ShortenedLength) ? ShortenedName : folder.Name; dr[7] = folder.OwnerFullName; dr[8] = reachable; dr[9] = folder.Name; dr[10] = folder.Preference; dt.Rows.Add(dr); reachable = true; } // If the page size is not full, finish it with empty entries. for (int i = dt.Rows.Count; i < iFolderList.PageSize; ++i) { dr = dt.NewRow(); dr[0] = false; dr[1] = String.Empty; dr[2] = String.Empty; dr[3] = false; dr[4] = false; dr[5] = false; dr[6] = String.Empty; dr[7] = String.Empty; dr[8] = false; dr[9] = String.Empty; dr[10] = 0; dt.Rows.Add(dr); } // Remember the total number of users. TotaliFolders = list.Total; web.Url = currentServerURL; // Build the data view from the table. return(new DataView(dt)); }
/// <summary> /// Event handler that gets called when the save report button is clicked. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void OnSaveAdminRights_Click(object sender, EventArgs e) { string Status = "SUCCESS"; string GroupID = null; string GroupName = GroupList.SelectedValue; Hashtable ht = GroupHashTable; if (ht.ContainsKey(GroupName)) { GroupID = (string)GroupHashTable[GroupName]; } if (GroupName.Equals(GetString("NONE"))) { TopNav.ShowError(GetString("ERRORSELECTGROUP")); return; } long GroupDiskLimit = 1; string limitString = AggregateDiskQuotaText.Text; if (limitString == null || limitString == String.Empty) { limitString = "Unlimited"; } try { decimal limit = Convert.ToDecimal(limitString == "Unlimited" ? "-1" : limitString); if (limit > 0 || limitString == "Unlimited") { // Convert from megabytes back to bytes. GroupDiskLimit = limitString == "Unlimited" ? -1 : Convert.ToInt64(Decimal.Round(limit, 2) * 1048576); // Get the values from the rights field int RightsValue = GetSelectedRights(); ConnectMaster(); // call webservice and pass two parameters to commit. web.AddGroupAdministrator(GroupID, SecondaryAdmin, RightsValue); bool retval = web.SetAggregateDiskQuota(GroupID, GroupDiskLimit); if (retval == false) { TopNav.ShowError(GetString("INVALIDGROUPQUOTA")); return; } Response.Redirect( String.Format( "StatusPage.aspx?status={0}&secondaryadmin={1}&groupname={2}&op={3}", Status, SecondaryAdmin, GroupName, op)); //true ); DisconnectMaster(); } else { TopNav.ShowError(GetString("ERRORINVALIDQUOTA")); return; } } catch (FormatException) { TopNav.ShowError(GetString("ERRORINVALIDQUOTA")); return; } catch (OverflowException) { TopNav.ShowError(GetString("ERRORINVALIDQUOTA")); return; } catch { DisconnectMaster(); if (op == "ADD") { string errMsg = String.Format(GetString("ERRORCANNOTADDSECONDARYADMIN"), SecondaryAdmin); TopNav.ShowError(errMsg); return; } else if (op == "EDIT") { string errMsg = String.Format(GetString("ERRORCANNOTEDITSECONDARYADMIN"), SecondaryAdmin); TopNav.ShowError(errMsg); return; } } }
/// <summary> /// Event handler that gets called if a policy error occurs. /// </summary> /// <param name="source"></param> /// <param name="e"></param> private void OnPolicyError(object source, PolicyErrorArgs e) { TopNav.ShowError(e.Message, e.Exception); }
/// <summary> /// Event handler that gets called when OK button is clicked. /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void OnOkButton_Click(object source, EventArgs e) { string currentServerProxyDN = null; string currentServerProxyDNPwd = null; bool proxychagnestatus = true; if (!validOK()) { TopNav.ShowError(GetString("ENTERLDAPDETAILS")); return; } if (!DataValidated()) { TopNav.ShowError(GetString("ERRORINVALIDDATA")); return; } if (String.Compare(LdapProxyUserPwd.Text.Trim(), ConfirmLdapProxyUserPwd.Text.Trim()) != 0) { TopNav.ShowError(GetString("ERRORPROXYPASSWORDSDOESNOTMATCH")); return; } /// if ldap admin username and password is right, go ahead iFolderServer server = web.GetServer(ServerID); remoteweb = new iFolderAdmin(); remoteweb.PreAuthenticate = true; remoteweb.Credentials = web.Credentials; remoteweb.Url = server.PublicUrl + "/iFolderAdmin.asmx"; remoteweb.GetAuthenticatedUser(); server = remoteweb.GetServer(ServerID); LdapInfo ldapInfo = new LdapInfo(); ldapInfo.Host = LdapServer.Text.Trim(); ldapInfo.SearchContexts = LdapSearchContext.Text; ldapInfo.ProxyDN = LdapProxyUser.Text; currentServerProxyDN = LdapProxyUser.Text; ldapInfo.ProxyPassword = LdapProxyUserPwd.Text; currentServerProxyDNPwd = LdapProxyUserPwd.Text; ldapInfo.SSL = (LdapSslList.SelectedValue == GetString("YES")) ? true : false; try { remoteweb.SetLdapDetails(ldapInfo, LdapAdminName.Text.Trim(), LdapAdminPwd.Text, ServerID); //now the proxy user info changed, check if the same proxy is //used in any other servers. if (ldapInfo.ProxyDN != null && ldapInfo.ProxyPassword != null) { proxychagnestatus = UpdateProxyUserInfo(LdapAdminName.Text.Trim(), LdapAdminPwd.Text, currentServerProxyDN, currentServerProxyDNPwd); } } catch (Exception ex) { TopNav.ShowInfo(String.Format("{0} {1}", GetString("UNABLETOEDITLDAPDETAILS"), ex.Message)); GetLdapDetails(); return; } if (proxychagnestatus != false) { Response.Redirect(String.Format("ServerDetails.aspx?ID={0}", ServerID)); } }
/// <summary> /// Initializes the iFolder detail web controls. /// </summary> /// <returns>The name of the ifolder.</returns> private string GetiFolderDetails() { int exp = 0; while (exp < 10) { try { //Resolve the location of iFolder. iFolderLocation = web.GetiFolderLocation(iFolderID); if (iFolderLocation == null || iFolderLocation == String.Empty || iFolderLocation == "") { Thread.Sleep(1000); exp = exp + 1; } else { UriBuilder remoteurl = new UriBuilder(iFolderLocation); remoteurl.Path = (new Uri(web.Url)).PathAndQuery; web.Url = remoteurl.Uri.ToString(); break; } } catch { Thread.Sleep(1000); if (exp == 10) { Page.Response.Redirect(String.Format("iFolders.aspx")); return(null); } exp = exp + 1; } } iFolderDetails ifolder = null; try { ifolder = web.GetiFolderDetails(iFolderID); } catch (Exception ex) { if (ex.Message.IndexOf("iFolderDoesNotExistException") != -1) { Page.Response.Redirect(String.Format("UserDetails.aspx?id={0}&errormsg={1}", UserID, GetString("ERRORIFOLDERDOESNOTEXIST"))); } else { web.Url = currentServerURL; TopNav.ShowError(GetString("LOGINCONNECTFAILED")); } return(null); } string loggedinuserid = Session["UserID"] as String; preference = web.GetUserGroupRights(loggedinuserid, ifolder.OwnerID); if (preference == -1) { preference = 0xffff; } string ShortenedName = null; int ShortenedLength = 50; if (ifolder.Name.Length > ShortenedLength) { // make it of desired length ShortenedName = web.GetShortenedName(ifolder.Name, ShortenedLength); } Name.Text = (ifolder.Name.Length > ShortenedLength) ? ShortenedName : ifolder.Name; Description.Text = ifolder.Description; Owner.Text = ifolder.OwnerFullName; Owner.NavigateUrl = String.Format("UserDetails.aspx?id={0}", ifolder.OwnerID); //Size.Text = Utils.ConvertToUnitString( ifolder.Size, true, rm ); Directories.Text = ifolder.DirectoryCount.ToString(); Files.Text = ifolder.FileCount.ToString(); string IsOrphaned = web.IsOrphanediFolder(iFolderID); if (IsOrphaned.Equals("")) { Orphan.Text = GetString("NO"); AdoptButton.Text = GetString("ADOPT"); AdoptButton.Visible = false; } else { //it has returned the previous owner id of this orphaned ifolder Orphan.Visible = true; Orphan.Text = GetString("YES"); AdoptButton.Visible = true; string EncryptAlgorithm = ifolder.EncryptionAlgorithm; if (!(EncryptAlgorithm == null || (EncryptAlgorithm == String.Empty))) { // It is an encrypted ifolder AdoptButton.Enabled = false; } else { AdoptButton.Enabled = true; } } LastModified.Text = (ifolder.LastModified == DateTime.MinValue) ? Utils.ToDateTimeString(DateTime.Now) : Utils.ToDateTimeString(ifolder.LastModified); // Allow the browser to break up the path on separator boundries. string FullUnManagedPath = ifolder.UnManagedPath.Replace( Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString() + "<WBR>"); string tmp = FullUnManagedPath; if (FullUnManagedPath.Length > 170) { tmp = web.GetShortenedName(FullUnManagedPath, 170); } //Adding Server Name iFolderServer[] list = web.GetServers(); string name = null; ServerName.Text = null; foreach (iFolderServer server in list) { if (server.PublicUrl == iFolderLocation) { name = server.Name; break; } } if (name != null) { ServerName.Text = name; } UnManagedPath.Text = tmp; // web.Url = currentServerURL; string EncryptionAlgorithm = ifolder.EncryptionAlgorithm; if (!(EncryptionAlgorithm == null || (EncryptionAlgorithm == String.Empty)) || !MemberRightsChangeAllowed) { // It is an encrypted ifolder MemberAddButton.Enabled = false; } return(ifolder.Name); }