Ejemplo n.º 1
0
 /// <remarks/>
 public void UpdateUserAsync(string siteId, WebUser user, object userState) {
     if ((this.UpdateUserOperationCompleted == null)) {
         this.UpdateUserOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateUserOperationCompleted);
     }
     this.InvokeAsync("UpdateUser", new object[] {
                 siteId,
                 user}, this.UpdateUserOperationCompleted, userState);
 }
Ejemplo n.º 2
0
 /// <remarks/>
 public System.IAsyncResult BeginUpdateUser(string siteId, WebUser user, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("UpdateUser", new object[] {
                 siteId,
                 user}, callback, asyncState);
 }
Ejemplo n.º 3
0
 /// <remarks/>
 public void UpdateUserAsync(string siteId, WebUser user) {
     this.UpdateUserAsync(siteId, user, null);
 }
Ejemplo n.º 4
0
 /// <remarks/>
 public void UpdateSecuredUserAsync(int siteItemId, WebUser user)
 {
     this.UpdateSecuredUserAsync(siteItemId, user, null);
 }
Ejemplo n.º 5
0
 public void UpdateUser(string siteId, WebUser user) {
     this.Invoke("UpdateUser", new object[] {
                 siteId,
                 user});
 }
Ejemplo n.º 6
0
        public static int UpdateUser(int siteItemId, WebUser user)
        {
            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            // place log record
            TaskManager.StartTask("WEB_SITE", "UPDATE_SECURED_USER", siteItem.Name);
            TaskManager.ItemId = siteItemId;
            TaskManager.WriteParameter("User", user.Name);

            try
            {
                // update user
                WebServer web = GetWebServer(siteItem.ServiceId);
                web.UpdateUser(siteItem.SiteId, user);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
Ejemplo n.º 7
0
 public int UpdateSecuredUser(int siteItemId, WebUser user)
 {
     object[] results = this.Invoke("UpdateSecuredUser", new object[] {
                 siteItemId,
                 user});
     return ((int)(results[0]));
 }
Ejemplo n.º 8
0
		public void DeleteUser(string siteId, string userName)
		{
			string rootPath = GetSiteContentPath(siteId);
			WebUser user = new WebUser();
			user.Name = userName;

			// update users and groups
			UpdateUser(siteId, user, true);

			// update foleds
			DeleteNonexistentUsersAndGroups(rootPath);
		}
Ejemplo n.º 9
0
 public void UpdateUser(string siteId, WebUser user)
 {
     try
     {
         Log.WriteStart("'{0}' UpdateUser", ProviderSettings.ProviderName);
         WebProvider.UpdateUser(siteId, user);
         Log.WriteEnd("'{0}' UpdateUser", ProviderSettings.ProviderName);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("'{0}' UpdateUser", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
Ejemplo n.º 10
0
		private void UpdateUser(string siteId, WebUser user, bool deleteUser)
		{
			string rootPath = GetSiteContentPath(siteId);
			string usersPath = Path.Combine(rootPath, ProtectedUsersFile);

			// load users file
			List<string> lines = ReadFile(usersPath);

			// check if the user already exists
			List<string> updatedLines = new List<string>();
			bool exists = false;
			for (int i = 0; i < lines.Count; i++)
			{
				string line = lines[i];
				string updatedLine = line;

				int colonIdx = line.IndexOf(":");
				if (colonIdx != -1)
				{
					string username = line.Substring(0, colonIdx);
					string password = line.Substring(colonIdx + 1);
					if (String.Compare(username, user.Name, true) == 0)
					{
						// already exists
						exists = true;

						// check if we need to delete this user
						if (deleteUser)
							continue;

						// change password if required
						if (!String.IsNullOrEmpty(user.Password))
						{
							// change password
                            BsdDES des = new BsdDES();
                            password = des.Crypt(user.Password);

							// update line
							updatedLine = username + ":" + password;
						}
					}
				}

				updatedLines.Add(updatedLine);
			}

            if (!exists && !deleteUser)
            {
                // new user has been added
                BsdDES des = new BsdDES();
                updatedLines.Add(user.Name + ":" + des.Crypt(user.Password));
            }

			// save users file
			WriteFile(usersPath, updatedLines);

			if (user.Groups == null)
				user.Groups = new string[] { };

			// update groups
			// open groups file
			string groupsPath = Path.Combine(rootPath, ProtectedGroupsFile);
			List<string> groupLines = ReadFile(groupsPath);

			for (int i = 0; i < groupLines.Count; i++)
			{
				string groupLine = groupLines[i];
				int colonIdx = groupLine.IndexOf(":");
				if (colonIdx != -1)
				{
					string groupName = groupLine.Substring(0, colonIdx);
					string[] groupMembers = groupLine.Substring(colonIdx + 1).Split(' ');

					// check if user is assigned to this group
					bool assigned = false;
					for (int j = 0; j < user.Groups.Length; j++)
					{
						if (String.Compare(user.Groups[j], groupName, true) == 0)
						{
							assigned = true;
							break;
						}
					}

					// remove current user
					List<string> updatedMembers = new List<string>();
					for (int j = 0; j < groupMembers.Length; j++)
					{
						// user exists in the members
						// check if he should be really added to this group
						if (String.Compare(groupMembers[j], user.Name, true) == 0)
							continue;

						updatedMembers.Add(groupMembers[j]);
					}

					if (assigned)
						updatedMembers.Add(user.Name);

					// modify group line
					groupLines[i] = groupName + ":" + String.Join(" ", updatedMembers.ToArray());
				}
			} // end iterating groups

			// save group file
			WriteFile(groupsPath, groupLines);
		}
Ejemplo n.º 11
0
		public void UpdateUser(string siteId, WebUser user)
		{
			UpdateUser(siteId, user, false);
		}
Ejemplo n.º 12
0
		public WebUser GetUser(string siteId, string userName)
		{
			// load users file
			string rootPath = GetSiteContentPath(siteId);
			string usersPath = Path.Combine(rootPath, ProtectedUsersFile);
			List<string> lines = ReadFile(usersPath);

			// iterate through all lines
			WebUser user = null;
			for (int i = 0; i < lines.Count; i++)
			{
				string line = lines[i];

				int colonIdx = line.IndexOf(":");
				if (colonIdx != -1)
				{
					string username = line.Substring(0, colonIdx);
					string password = line.Substring(colonIdx + 1);
					if (String.Compare(username, userName, true) == 0)
					{
						// exists
						user = new WebUser();
						user.Name = username;
						user.Password = password;
						break;
					}
				}
			}

			if (user == null)
				return null; // user doesn't exist

			List<string> userGroups = new List<string>();

			// read groups information
			// open groups file
			string groupsPath = Path.Combine(rootPath, ProtectedGroupsFile);
			List<string> groupLines = ReadFile(groupsPath);

			for (int i = 0; i < groupLines.Count; i++)
			{
				string groupLine = groupLines[i];
				int colonIdx = groupLine.IndexOf(":");
				if (colonIdx != -1)
				{
					string groupName = groupLine.Substring(0, colonIdx);
					string[] groupMembers = groupLine.Substring(colonIdx + 1).Split(' ');

					// check group members
					for (int j = 0; j < groupMembers.Length; j++)
					{
						if (String.Compare(groupMembers[j], user.Name, true) == 0)
						{
							userGroups.Add(groupName);
							break;
						}
					}
				}
			} // end iterating groups
			user.Groups = userGroups.ToArray();

			return user;
		}
        private void SaveUser()
        {
            WebUser user = new WebUser();
            user.Name = usernameControl.Text;
            user.Password = passwordControl.Password;

            List<string> groups = new List<string>();
            foreach (ListItem li in dlGroups.Items)
                if (li.Selected)
                    groups.Add(li.Value);

            user.Groups = groups.ToArray();

            try
            {
                int result = ES.Services.WebServers.UpdateSecuredUser(PanelRequest.ItemID, user);
                if (result < 0)
                {
                    ShowResultMessage(result);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("WEB_UPDATE_SECURED_USER", ex);
                return;
            }

            ReturnBack();
        }
Ejemplo n.º 14
0
 public int UpdateSecuredUser(int siteItemId, WebUser user)
 {
     return WebServerController.UpdateUser(siteItemId, user);
 }