Example #1
0
        /// <summary>
        /// Creates a DataSource containing user names from a search.
        /// </summary>
        /// <returns>An DataView object containing the ifolder users.</returns>
        private DataView CreateMemberList()
        {
            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("NameField", typeof(string)));
            dt.Columns.Add(new DataColumn("FullNameField", typeof(string)));

            iFolderUserSet userList = web.GetUsersBySearch(
                MemberSearch.SearchAttribute,
                MemberSearch.SearchOperation,
                (MemberSearch.SearchName == String.Empty) ? "*" : MemberSearch.SearchName,
                CurrentUserOffset,
                MemberList.PageSize);

            foreach (iFolderUser user in userList.Items)
            {
                dr    = dt.NewRow();
                dr[0] = true;
                dr[1] = user.ID;
                dr[2] = user.UserName;
                dr[3] = user.FullName;

                dt.Rows.Add(dr);
            }

            // If the page size is not full, finish it with empty entries.
            for (int i = dt.Rows.Count; i < MemberList.PageSize; ++i)
            {
                dr    = dt.NewRow();
                dr[0] = false;
                dr[1] = String.Empty;
                dr[2] = String.Empty;
                dr[3] = String.Empty;

                dt.Rows.Add(dr);
            }

            // Remember the total number of users.
            TotalUsers = userList.Total;

            // Save the data table.
            MemberListSource = dt;

            // Build the data view from the table.
            return(new DataView(dt));
        }
Example #2
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindCurrentMembersData()
        {
            try
            {
                // name
                iFolder ifolder = web.GetiFolder(ifolderID);
                iFolderName.Text = ifolder.Name;

                // current members
                iFolderUserSet members = web.GetMembers(ifolderID, 0, 0);

                foreach (iFolderUser member in members.Items)
                {
                    currentMembers.Add(member.ID, member.UserName);
                }
            }
            catch (SoapException ex)
            {
                if (!HandleException(ex))
                {
                    throw;
                }
            }
        }
Example #3
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindUserData()
        {
            // keep search pattern consistent
            SearchPattern.Text = (string)ViewState["SearchPattern"];

            // user
            DataTable userTable = new DataTable();

            userTable.Columns.Add("ID");
            userTable.Columns.Add("FullName");
            userTable.Columns.Add("Enabled", typeof(bool));

            try
            {
                // user
                SearchProperty prop = (SearchProperty)Enum.Parse(typeof(SearchProperty), SearchPropertyList.SelectedItem.Value);

                iFolderUserSet users = web.GetUsersBySearch(
                    prop, SearchOperation.BeginsWith, SearchPattern.Text,
                    UserPagging.Index, UserPagging.PageSize);
                UserPagging.Count = users.Items.Length;
                UserPagging.Total = users.Total;

                string name;

                foreach (iFolderUser user in users.Items)
                {
                    DataRow row = userTable.NewRow();

                    // display name
                    switch (prop)
                    {
                    case SearchProperty.UserName:
                        name = user.UserName;
                        break;

                    case SearchProperty.LastName:
                        name = String.Format("{0}{1}{2}", user.LastName,
                                             GetString("LASTFIRSTNAMESEP"), user.FirstName);
                        break;

                    case SearchProperty.FirstName:
                    default:
                        name = String.Format("{0}{1}{2}", user.FirstName,
                                             GetString("FIRSTLASTNAMESEP"), user.LastName);
                        break;
                    }

                    row["ID"]       = user.ID;
                    row["FullName"] = name;
                    row["Enabled"]  = !members.ContainsKey(user.ID) && !currentMembers.ContainsKey(user.ID);

                    userTable.Rows.Add(row);
                }
            }
            catch (SoapException ex)
            {
                if (!HandleException(ex))
                {
                    throw;
                }
            }

            // bind
            UserData.DataSource   = userTable;
            UserData.DataKeyField = "ID";
            UserData.DataBind();
        }
Example #4
0
        /// <summary>
        /// Creates a DataSource containing user names from a search.
        /// </summary>
        /// <returns>An DataView object containing the ifolder users.</returns>
        private DataView CreateDataSource()
        {
            // store the server list , so that it can be used to fill up the drop down box for each user and need not make
            // calls for each user

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("VisibleField", typeof(bool)));
            dt.Columns.Add(new DataColumn("IDField", typeof(string)));
            dt.Columns.Add(new DataColumn("AdminField", typeof(bool)));
            dt.Columns.Add(new DataColumn("ProvisionedField", typeof(string)));
            dt.Columns.Add(new DataColumn("NameField", typeof(string)));
            dt.Columns.Add(new DataColumn("CurrentHomeField", typeof(string)));
            dt.Columns.Add(new DataColumn("NewHomeField", typeof(string)));
            dt.Columns.Add(new DataColumn("PercentageStatusField", typeof(string)));
            dt.Columns.Add(new DataColumn("StatusField", typeof(string)));
            dt.Columns.Add(new DataColumn("DeleteField", typeof(bool)));

            DataRow dr;

            iFolderUserSet userList = web.GetReprovisionUsers(
                CurrentUserOffset,
                Accounts.PageSize);

            foreach (iFolderUser user in userList.Items)
            {
                string             newHomeUrl = user.NewHomeServerUrl;
                iFolderUserDetails details    = null;
                if (!String.IsNullOrEmpty(newHomeUrl))
                {
                    UriBuilder remoteurl = new UriBuilder(newHomeUrl);
                    remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                    web.Url        = remoteurl.Uri.ToString();

                    try
                    {
                        details = web.GetUserDetails(user.ID);
                    }
                    catch
                    {
                        web.Url = currentServerURL;
                        details = web.GetUserDetails(user.ID);
                    }
                }

                dr    = dt.NewRow();
                dr[0] = true;
                dr[1] = user.ID;
                dr[2] = (user.MemberRights == Rights.Admin) ? true : false;
                dr[3] = (user.HomeServer == string.Empty) ?  null : user.HomeServer;
                dr[4] = user.UserName;
                dr[5] = (user.HomeServer == string.Empty) ?  null : user.HomeServer;
                dr[6] = (user.NewHomeServer == string.Empty) ?  null : user.NewHomeServer;
                dr[7] = details != null ? (details.DetailDataMovePercentage.ToString() + " %   ") : user.DataMovePercentage.ToString() + " %   ";
                string dataMoveStatus = details != null ? details.DetailDataMoveStatus : user.DataMoveStatus;
                dr [8] = (string.Compare(dataMoveStatus, "NOTELIGIBLE") == 0) ? GetString(dataMoveStatus): dataMoveStatus;
                if (string.Compare(dataMoveStatus, "NOTELIGIBLE") == 0)
                {
                    dr[9] = true;
                }
                else
                {
                    dr[9] = false;
                }

                dt.Rows.Add(dr);
            }

            // If the page size is not full, finish it with empty entries.
            for (int i = dt.Rows.Count; i < Accounts.PageSize; ++i)
            {
                dr    = dt.NewRow();
                dr[0] = false;
                dr[1] = String.Empty;
                dr[2] = false;
                dr[3] = false;
                dr[4] = null;
                dr[5] = String.Empty;
                dr[6] = String.Empty;
                dr[7] = String.Empty;
                dr[8] = String.Empty;
                dr[9] = false;

                dt.Rows.Add(dr);
            }

            // Remember the total number of users.
            TotalUsers = userList.Total;

            web.Url = currentServerURL;

            // Build the data view from the table.
            return(new DataView(dt));
        }
Example #5
0
        /// <summary>
        /// Initializes the time of day values in the dropdown list.
        /// </summary>
        public void InitializeGroupList()
        {
            string Operation = op;

            //string [] GroupListStr ;//= null;
            GroupHashTable = new Hashtable();

            // Call web-service to get the groups for which this user is secondary admin

            if (Operation == "ADD")
            {
                // This will search only groups from whole domain
                iFolderUserSet userList = web.GetUsersBySearch(
                    SearchProperty.GroupOnly,
                    SearchOperation.BeginsWith,
                    "*",
                    0,
                    0);
                //string [] GroupStr = new string[ userList.Total ];
                string [] MonitoredGroupsIDs = web.GetMonitoredGroups(SecondaryAdmin);

                GroupList.Items.Add(GetString("NONE"));
                foreach (iFolderUser user in userList.Items)
                {
                    if ((MonitoredGroupsIDs == null || MonitoredGroupsIDs.Length == 0) || Array.IndexOf(MonitoredGroupsIDs, user.ID) < 0)
                    {
                        // Add only those groups which are not monitored currently by this secondary admin
                        GroupHashTable[user.FullName] = user.ID;
                        GroupList.Items.Add(user.FullName);
                    }
                }
                GroupList.SelectedIndex = 0;
            }
            else if (Operation == "EDIT")
            {
                // get all groups for which this member is an admin

                iFolderUser user = web.GetUser(GroupID);
                if (GroupID != "")
                {
                    GroupHashTable[user.FullName] = user.ID;
                    GroupList.Items.Add(user.FullName);
                    GroupList.SelectedIndex = 0;
                    GroupList.Enabled       = false;

                    long limit = web.GetAggregateDiskQuota(GroupID);
                    if (limit == -1)
                    {
                        AggregateDiskQuotaText.Text = "";
                    }
                    else
                    {
                        AggregateDiskQuotaText.Text = Utils.ConvertToMBString(limit, false, rm);
                    }
                    ShowSecondaryAdminRights(GroupID);
                }


                //AggregateDiskQuotaText.Text = "100";
                SaveAdminRights.Enabled = true;
            }
        }
Example #6
0
        /// <summary>
        /// Gets the displayable ifolder system information.
        /// </summary>
        private void GetSystemInformation()
        {
            iFolderSystem system = web.GetSystem();

            Name.Text         = system.Name;
            Description.Value = system.Description;
            if (system.UsersFullNameDisplay == "FirstNameLastName")
            {
                FullNameSetting.SelectedIndex = 0;
            }
            else
            {
                FullNameSetting.SelectedIndex = 1;
            }
            if (system.GroupSegregated == "yes")
            {
                GroupSegregated.Checked = true;
            }

            if (system.GroupQuotaRestrictionMethod == (int)QuotaRestriction.UI_Based)
            {
                GroupQuotaRestriction.SelectedIndex = 0;
            }
            else if (system.GroupQuotaRestrictionMethod == (int)QuotaRestriction.Sync_Based)
            {
                GroupQuotaRestriction.SelectedIndex = 1;
            }

            iFolderUserSet users = web.GetUsers(0, 1);

            NumberOfUsers.Text = users.Total.ToString();

            iFolderSet ifolders = web.GetiFolders(iFolderType.All, 0, 1);

            NumberOfiFolders.Text = ifolders.Total.ToString();

            web.Url = currentServerURL;
            iFolderServer[] list = web.GetServers();
            foreach (iFolderServer server in list)
            {
                if (server.IsLocal)
                {
                    UriBuilder remoteurl = new UriBuilder(server.PublicUrl);
                    remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
                    web.Url        = remoteurl.Uri.ToString();

                    string [] SSlOptionsStr = new string [3];
                    SSlOptionsStr[0] = GetString("SSLSTRING");
                    SSlOptionsStr[1] = GetString("NONSSLSTRING");
                    SSlOptionsStr[2] = GetString("BOTHSTRING");
                    string     SelectedString  = "";
                    string     simiassslstatus = web.GetSimiasRequiresSSLStatus();
                    UriBuilder urlforssl       = new UriBuilder(web.Url);
                    if (urlforssl.Scheme == Uri.UriSchemeHttps)
                    {
                        if (simiassslstatus == "no")
                        {
                            SelectedString = GetString("BOTHSTRING");
                        }
                        else
                        {
                            SelectedString = GetString("SSLSTRING");
                        }
                    }
                    else
                    {
                        SelectedString = GetString("NONSSLSTRING");
                    }
                    SSLValue.DataSource = SSlOptionsStr;
                    SSLValue.DataBind();
                    SSLValue.SelectedValue = SelectedString;
                    break;
                }
            }
            SSLValue.Enabled = false;
            // SSLOption was server specific, now connect back to master
            ConnectToMaster();
        }
Example #7
0
        /// <summary>
        /// Gets the list view of ifolder administrators.
        /// </summary>
        /// <returns></returns>
        private DataView CreateDataSource()
        {
            DataTable      dt = new DataTable();
            DataRow        dr;
            iFolderUserSet adminList = null;

            dt.Columns.Add(new DataColumn("VisibleField", typeof(bool)));
            dt.Columns.Add(new DataColumn("IDField", typeof(string)));
            dt.Columns.Add(new DataColumn("NameField", typeof(string)));
            dt.Columns.Add(new DataColumn("FullNameField", typeof(string)));
            dt.Columns.Add(new DataColumn("GroupListVisibleField", typeof(bool)));
            dt.Columns.Add(new DataColumn("NAField", typeof(string)));


            switch (ActiveAdminTab)
            {
            case ListDisplayType.GroupAdmins:
                adminList = web.GetAdministrators(CurrentAdminOffset, AdminList.PageSize, (int)ListDisplayType.GroupAdmins);
                AllAdminsCheckBox.Enabled = false;
                AllAdminsCheckBox.Checked = false;
                break;

            case ListDisplayType.PrimaryAdmins:
            default:
                adminList = web.GetAdministrators(CurrentAdminOffset, AdminList.PageSize, (int)ListDisplayType.PrimaryAdmins);
                AllAdminsCheckBox.Enabled = true;
                break;
            }

            foreach (iFolderUser admin in adminList.Items)
            {
                dr    = dt.NewRow();
                dr[0] = true;
                dr[1] = admin.ID;
                dr[2] = admin.UserName;
                dr[3] = admin.FullName;
                dr[4] = !(AllAdminsCheckBox.Enabled);                           //if it system admin tab, then do not show the group list
                dr[5] = "";

                dt.Rows.Add(dr);
            }

            // If the page size is not full, finish it with empty entries.
            for (int i = dt.Rows.Count; i < AdminList.PageSize; ++i)
            {
                dr    = dt.NewRow();
                dr[0] = false;
                dr[1] = String.Empty;
                dr[2] = String.Empty;
                dr[3] = String.Empty;
                dr[4] = false;
                dr[5] = String.Empty;
                //dr[ 6 ] = false;

                dt.Rows.Add(dr);
            }

            // Remember the total number of users.
            TotalAdmins = adminList.Total;

            // Build the data view from the table.
            return(new DataView(dt));
        }
Example #8
0
        /// <summary>
        /// Gets the member list view for the specified ifolder.
        /// </summary>
        /// <returns></returns>
        private DataView GetiFolderMemberList(bool AdoptButtonClicked)
        {
            DataTable      dt = new DataTable();
            DataRow        dr;
            iFolderUserSet userList   = null;
            iFolderUserSet memberList = null;

            dt.Columns.Add(new DataColumn("VisibleField", typeof(bool)));
            dt.Columns.Add(new DataColumn("OwnerField", typeof(bool)));
            dt.Columns.Add(new DataColumn("IDField", typeof(string)));
            dt.Columns.Add(new DataColumn("FullNameField", typeof(string)));
            dt.Columns.Add(new DataColumn("UserNameField", typeof(string)));
            dt.Columns.Add(new DataColumn("RightsField", typeof(string)));
            iFolderLocation = web.GetiFolderLocation(iFolderID);
            UriBuilder remoteurl = new UriBuilder(iFolderLocation);

            remoteurl.Path = (new Uri(web.Url)).PathAndQuery;
            web.Url        = remoteurl.Uri.ToString();
            try
            {
                memberList =
                    web.GetMembers(
                        iFolderID,
                        CurrentMemberOffset,
                        iFolderMemberList.PageSize);
            }
            catch
            {
                return(new DataView(dt));
            }


            foreach (iFolderUser member in memberList.Items)
            {
                dr    = dt.NewRow();
                dr[0] = true;
                dr[1] = member.IsOwner;
                dr[2] = member.ID;
                dr[3] = member.FullName;
                dr[4] = member.UserName;
                if (member.MemberRights == Rights.Admin)
                {
                    if (member.IsOwner)
                    {
                        dr[5] = GetString("OWNER");
                    }
                    else
                    {
                        dr[5] = GetString("FULLCONTROL");
                    }
                }
                else
                {
                    string attribute = member.MemberRights.ToString();
                    if (attribute == Rights.ReadWrite.ToString())
                    {
                        dr[5] = GetString("READWRITE");
                    }
                    else if (attribute == Rights.ReadOnly.ToString())
                    {
                        dr[5] = GetString("READONLY");
                    }
                }

                dt.Rows.Add(dr);
            }

            //if Adopt button was clicked, then show all the users from domain
            if (AdoptButtonClicked)
            {
                // userList if adoptButton was clicked
                userList = web.GetUsers(
                    CurrentMemberOffset,
                    iFolderMemberList.PageSize);

                int NoOfRows = dt.Rows.Count;

                foreach (iFolderUser user in userList.Items)
                {
                    bool UserAlready = false;
                    for (int i = 0; i < NoOfRows; i++)
                    {
                        if (user.ID == (String)dt.Rows[i][2])
                        {
                            UserAlready = true;
                            break;
                        }
                    }

                    if (!UserAlready)
                    {
                        dr    = dt.NewRow();
                        dr[0] = true;
                        dr[1] = false;
                        dr[2] = user.ID;
                        dr[3] = user.FullName;
                        dr[4] = String.Format("<font color=red>" + GetString("NOTAPPLICABLE") + "</font>");

                        dt.Rows.Add(dr);
                    }
                }

                AdoptButton.Enabled = false;
            }


            // If the page size is not full, finish it with empty entries.
            for (int i = dt.Rows.Count; i < iFolderMemberList.PageSize; ++i)
            {
                dr    = dt.NewRow();
                dr[0] = false;
                dr[1] = false;
                dr[2] = String.Empty;
                dr[3] = String.Empty;
                dr[4] = String.Empty;
                dr[5] = String.Empty;

                dt.Rows.Add(dr);
            }

            // Remember the total number of users.
            if (AdoptButtonClicked)
            {
                TotaliFolderMembers = userList.Total;
            }
            else
            {
                TotaliFolderMembers = memberList.Total;
            }

            // Build the data view from the table.
            return(new DataView(dt));
        }
Example #9
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindMemberData()
        {
            // member
            DataTable memberTable = new DataTable();

            memberTable.Columns.Add("ID");
            memberTable.Columns.Add("Name");
            memberTable.Columns.Add("UserName");
            memberTable.Columns.Add("Rights");
            memberTable.Columns.Add("Enabled", typeof(bool));
            memberTable.Columns.Add("iFolderID");

            try
            {
                // ifolder
                iFolder ifolder = web.GetiFolder(ifolderID);
                string  ownerID = ifolder.OwnerID;
                bool    flag    = false;

                // rights
                Actions.Visible               = (ifolder.MemberRights == Rights.Admin);
                ActionsOwner.Visible          = ifolder.IsOwner;
                MemberData.Columns[1].Visible = Actions.Visible;

                // member
                iFolderUserSet members = web.GetMembers(ifolderID, MemberPagging.Index, MemberPagging.PageSize);
                MemberPagging.Count = members.Items.Length;
                MemberPagging.Total = members.Total;
                string accessID = (Session["User"] as iFolderUser).ID;
                foreach (iFolderUser member in members.Items)
                {
                    if (member.ID == accessID)
                    {
                        flag = true;
                        break;
                    }
                }

                foreach (iFolderUser member in members.Items)
                {
                    DataRow row = memberTable.NewRow();

                    row["ID"]        = member.ID;
                    row["Name"]      = (member.FullName == "") ? member.UserName : member.FullName;
                    row["UserName"]  = member.UserName;
                    row["Rights"]    = member.IsOwner ? GetString("OWNER") : WebUtility.FormatRights(member.MemberRights, rm);
                    row["Enabled"]   = IsCheckBoxEnabled(member, accessID, ownerID, flag);
                    row["iFolderID"] = ifolderID;

                    memberTable.Rows.Add(row);
                }
            }
            catch (SoapException ex)
            {
                if (!HandleException(ex))
                {
                    throw;
                }
            }

            // bind
            MemberData.DataSource = memberTable;
            MemberData.DataBind();
        }
Example #10
0
        /// <summary>
        /// Creates a DataSource containing user names from a search.
        /// </summary>
        /// <returns>An DataView object containing the ifolder users.</returns>
        private DataView CreateDataSource()
        {
            int NameWidth = 24;             //this is a magic number that is used to display the username and

            //fullname in shortened format.
            // store the server list , so that it can be used to fill up the drop down box for each user and need not make
            // calls for each user
            ServerList = GetServerList();

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("VisibleField", typeof(bool)));
            dt.Columns.Add(new DataColumn("IDField", typeof(string)));
            dt.Columns.Add(new DataColumn("DisabledField", typeof(bool)));
            dt.Columns.Add(new DataColumn("AdminField", typeof(bool)));
            dt.Columns.Add(new DataColumn("ProvisionedField", typeof(string)));
            dt.Columns.Add(new DataColumn("NameField", typeof(string)));
            dt.Columns.Add(new DataColumn("FullNameField", typeof(string)));
            dt.Columns.Add(new DataColumn("StatusField", typeof(string)));
            dt.Columns.Add(new DataColumn("PreferenceField", typeof(string)));

            DataRow dr;

            iFolderUserSet userList = web.GetUsersBySearch(
                MemberSearch.SearchAttribute,
                MemberSearch.SearchOperation,
                (MemberSearch.SearchName == String.Empty) ? "*" : MemberSearch.SearchName,
                CurrentUserOffset,
                Accounts.PageSize);

            foreach (iFolderUser user in userList.Items)
            {
                dr    = dt.NewRow();
                dr[0] = true;
                dr[1] = user.ID;
                dr[2] = !user.Enabled;
                dr[3] = (user.MemberRights == Rights.Admin) ? true : false;
                dr[4] = (user.HomeServer == string.Empty) ?  null : user.HomeServer;
                dr[5] = (user.UserName.Length > NameWidth) ? web.GetShortenedName(user.UserName, NameWidth) : user.UserName;
                dr[6] = (user.UserName.Length > NameWidth) ? web.GetShortenedName(user.FullName, NameWidth) : user.FullName;
                dr[7] = GetString(user.Enabled ? "YES" : "NO");
                dr[8] = Convert.ToString(user.Preference);

                dt.Rows.Add(dr);
            }

            // If the page size is not full, finish it with empty entries.
            for (int i = dt.Rows.Count; i < Accounts.PageSize; ++i)
            {
                dr    = dt.NewRow();
                dr[0] = false;
                dr[1] = String.Empty;
                dr[2] = false;
                dr[3] = false;
                dr[4] = null;
                dr[5] = String.Empty;
                dr[6] = String.Empty;
                dr[7] = String.Empty;
                dr[8] = "0";

                dt.Rows.Add(dr);
            }

            // Remember the total number of users.
            TotalUsers = userList.Total;

            // Build the data view from the table.
            return(new DataView(dt));
        }
Example #11
0
      /// <summary>
      /// Main to start the execution
      /// </summary>
      /// <param name="args"></param>
      public static void Main(string[] args)
      {
          if (args.Length == 0)
          {
              Console.WriteLine("A command line utility to manage users in a Simias Server domain.");
              Console.WriteLine("UserCmd.exe action <options>");
              return;
          }

          ParseCommandLine(args);

          if (action == "help")
          {
              ShowUseage();
              return;
          }

          if (action == null || url == null)
          {
              Console.WriteLine("missing mandatory command line arguments");
              return;
          }

          if (adminName == null)
          {
              Console.Write("Please enter simias admin: ");
              adminName = Console.ReadLine();

              Console.Write("password: "******"/\:";

          admin.Url  = url.TrimEnd(notEndingWith.ToCharArray());
          admin.Url += "/simias10/iFolderAdmin.asmx";

          if (action == "create")
          {
              if (username == null || password == null)
              {
                  Console.WriteLine("missing mandatory command line arguments");
                  return;
              }

              // Make the web service call to register/create the user
              iFolderUser user = null;

              try
              {
                  user = admin.CreateUser(
                      username,
                      password,
                      null,
                      first,
                      last,
                      full,
                      null,
                      email);

                  if (user != null)
                  {
                      Console.WriteLine("Successful");
                  }
              }
              catch (WebException we)
              {
                  if (we.Message.LastIndexOf("401") != 0)
                  {
                      Console.WriteLine("Failed - Invalid admin credentials");
                  }
                  else
                  {
                      Console.Write("Failed - ");
                      Console.WriteLine(we.Message);
                  }
              }
              catch (Exception ex)
              {
                  Console.WriteLine("Failed creating {0}'s account", username);
              }
          }
          else
          if (action == "delete")
          {
              try
              {
                  bool status = admin.DeleteUser(username);
                  if (verbose == true)
                  {
                      Console.WriteLine("Deleting user {0}  Status {1)", username, status.ToString());
                  }
              }
              catch (WebException we)
              {
                  if (we.Message.LastIndexOf("401") != 0)
                  {
                      Console.WriteLine("Failed - Invalid admin credentials");
                  }
                  else
                  {
                      Console.Write("Failed - ");
                      Console.WriteLine(we.Message);
                  }
              }
              catch (Exception ex)
              {
                  Console.WriteLine("Failed deleting {0}'s account", username);
              }
          }
          else
          if (action == "modify")
          {
              iFolderUser user      = null;
              bool        exception = false;
              try
              {
                  user = admin.GetUser(username);
              }
              catch (WebException we)
              {
                  if (we.Message.LastIndexOf("401") != 0)
                  {
                      Console.WriteLine("Failed - Invalid admin credentials");
                  }
                  else
                  {
                      Console.Write("Failed - ");
                      Console.WriteLine(we.Message);
                  }
                  exception = true;
              }
              catch (Exception ex)
              {
                  Console.WriteLine("Failed deleting {0}'s account", username);
                  exception = true;
              }

              if (user != null)
              {
                  if (quota != null)
                  {
                      bool       changed    = false;
                      UserPolicy userPolicy = admin.GetUserPolicy(user.ID, null);
                      if (quota != null)
                      {
                          if (verbose == true)
                          {
                              Console.WriteLine("Changing quota from {0} to {1}", userPolicy.SpaceLimit, Convert.ToInt64(quota));
                          }
                          userPolicy.SpaceLimit = Convert.ToInt64(quota);
                          changed = true;
                      }

                      if (changed == true)
                      {
                          admin.SetUserPolicy(userPolicy);
                      }
                  }

                  if (email != null || first != null || last != null || full != null)
                  {
                      if (first != null)
                      {
                          user.FirstName = first;
                      }

                      if (last != null)
                      {
                          user.LastName = last;
                      }

                      if (full != null)
                      {
                          user.FullName = full;
                      }

                      if (email != null)
                      {
                          user.Email = email;
                      }

                      // Write the changes
                      admin.SetUser(user.ID, user);
                  }

                  if (password != null)
                  {
                      bool status = admin.SetPassword(username, password);
                      if (verbose == true)
                      {
                          Console.WriteLine("SetPassord for {0} - {1}", username, status.ToString());
                      }
                  }
              }
              else if (exception == false)
              {
                  Console.WriteLine("Failed - user {0} does not exist", username);
              }
          }
          else
          if (action == "list")
          {
              try
              {
                  iFolderUserSet userSet = admin.GetUsers(0, 0);
                  //admin.GetUsersBySearch( SearchProperty.UserName, SearchOperation.BeginsWith, "*", 0, 0 );

                  foreach (iFolderUser user in userSet.Items)
                  {
                      Console.Write("ID: {0}  ", user.ID);
                      Console.Write("User: {0}  ", user.UserName);
                      if (user.FullName != null && user.FullName != "")
                      {
                          Console.Write("Fullname: {0}  ", user.FullName);
                      }

                      Console.Write("Enabled: {0}  ", user.Enabled.ToString());
                      Console.WriteLine();
                  }
              }
              catch (WebException we)
              {
                  if (we.Message.LastIndexOf("401") != 0)
                  {
                      Console.WriteLine("Failed - Invalid admin credentials");
                  }
                  else
                  {
                      Console.Write("Failed - ");
                      Console.WriteLine(we.Message);
                  }
              }
              catch (Exception ex)
              {
                  Console.WriteLine("Failed getting a list of users");
              }
          }
          else
          if (action == "setpwd")
          {
              if (username == null || username == String.Empty || password == null)
              {
                  Console.WriteLine("missing mandatory command line arguments");
                  return;
              }

              try
              {
                  bool status = admin.SetPassword(username, password);
                  Console.WriteLine("SetPassord for {0} - {1}", username, status.ToString());
              }
              catch (WebException we)
              {
                  if (we.Message.LastIndexOf("401") != 0)
                  {
                      Console.WriteLine("Failed - Invalid admin credentials");
                  }
                  else
                  {
                      Console.Write("Failed - ");
                      Console.WriteLine(we.Message);
                  }
              }
              catch (Exception ex)
              {
                  Console.WriteLine("Failed setting {0}'s password", username);
              }
          }
          else
          {
              Console.WriteLine("Error: invalid action");
          }

          return;
      }