public static int AddSharePointGroup(SystemGroup item)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // check package
            int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive);
            if (packageCheck < 0) return packageCheck;

            // check quota
            QuotaValueInfo quota = PackageController.GetPackageQuota(item.PackageId, Quotas.SHAREPOINT_GROUPS);
            if (quota.QuotaExhausted)
                return BusinessErrorCodes.ERROR_SHAREPOINT_GROUPS_RESOURCE_QUOTA_LIMIT;

            // check if mail resource is available
            int serviceId = PackageController.GetPackageServiceId(item.PackageId, ResourceGroups.SharePoint);
            if (serviceId == 0)
                return BusinessErrorCodes.ERROR_SHAREPOINT_RESOURCE_UNAVAILABLE;

            // check package items
            if (PackageController.GetPackageItemByName(item.PackageId, ResourceGroups.SharePoint, item.Name, typeof(SystemGroup)) != null)
                return BusinessErrorCodes.ERROR_SHAREPOINT_GROUPS_PACKAGE_ITEM_EXISTS;

            // place log record
            TaskManager.StartTask("SHAREPOINT", "ADD_GROUP", item.Name);

            try
            {
                // check service items
                SharePointServer sps = GetSharePoint(serviceId);
                if (sps.GroupExists(item.Name))
                    return BusinessErrorCodes.ERROR_SHAREPOINT_GROUPS_SERVICE_ITEM_EXISTS;

                item.Description = "WebsitePanel System Group";

                // add service item
                sps.CreateGroup(item);

                // save item
                item.ServiceId = serviceId;
                int itemId = PackageController.AddPackageItem(item);

                TaskManager.ItemId = itemId;

                return itemId;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
예제 #2
0
        public override string[] Install()
        {
            List<string> messages = new List<string>();

            try
            {
                SecurityUtils.EnsureOrganizationalUnitsExist(ServerSettings, UsersOU, GroupsOU);
            }
            catch (Exception ex)
            {
				Log.WriteError(ex);
                messages.Add(String.Format("Could not check/create Organizational Units: {0}", ex.Message));
                return messages.ToArray();
            }

            // create web group name
            if (String.IsNullOrEmpty(WebGroupName))
            {
                messages.Add("Web Group can not be blank");
            }
            else
            {
                try
                {
                    // create group
                    if (!SecurityUtils.GroupExists(WebGroupName, ServerSettings, GroupsOU))
                    {
                        SystemGroup group = new SystemGroup();
                        group.Name = WebGroupName;
                        group.Members = new string[] { };
                        group.Description = "WebsitePanel System Group";

                        SecurityUtils.CreateGroup(group, ServerSettings, UsersOU, GroupsOU);
                    }
                }
                catch (Exception ex)
                {
					Log.WriteError(ex);
                    messages.Add(String.Format("There was an error while adding '{0}' group: {1}",
                        WebGroupName, ex.Message));
                }
            }

			#region Create ASP.NET application pools
			try
			{
				if (!ApplicationPoolExists(Asp11Pool))
					CreateApplicationPool(Asp11Pool, "", "");
			}
			catch (Exception ex)
			{
				messages.Add(String.Format("There was an error while creating '{0}' pool: {1}",
					Asp11Pool, ex.Message));
			}

			try
			{
				if (!ApplicationPoolExists(Asp20Pool))
					CreateApplicationPool(Asp20Pool, "", "");
			}
			catch (Exception ex)
			{
				messages.Add(String.Format("There was an error while creating '{0}' pool: {1}",
					Asp20Pool, ex.Message));
			}

			try
			{
				if (!ApplicationPoolExists(Asp40Pool))
					CreateApplicationPool(Asp40Pool, "", "");
			}
			catch (Exception ex)
			{
				messages.Add(String.Format("There was an error while creating '{0}' pool: {1}",
					Asp40Pool, ex.Message));
			} 
			#endregion

            // check script processors
            string aspPath = FileUtils.GetExecutablePathWithoutParameters(AspPath);
            string aspNet11Path = FileUtils.GetExecutablePathWithoutParameters(AspNet11Path);
            string aspNet20Path = FileUtils.GetExecutablePathWithoutParameters(AspNet20Path);
			string aspNet40Path = FileUtils.GetExecutablePathWithoutParameters(AspNet40Path);
            string php4Path = FileUtils.GetExecutablePathWithoutParameters(Php4Path);
            string php5Path = FileUtils.GetExecutablePathWithoutParameters(Php5Path);
            string perlPath = FileUtils.GetExecutablePathWithoutParameters(PerlPath);
            string pythonPath = FileUtils.GetExecutablePathWithoutParameters(PythonPath);
            string securedFoldersFilterPath = FileUtils.GetExecutablePathWithoutParameters(SecuredFoldersFilterPath);
            string coldfusionPath = FileUtils.GetExecutablePathWithoutParameters(ColdFusionPath);
            string cfscriptsdirPath = FileUtils.GetExecutablePathWithoutParameters(CFScriptsDirectoryPath);
            string cfflashdirectoryPath = FileUtils.GetExecutablePathWithoutParameters(CFFlashRemotingDirPath);

            if (!String.IsNullOrEmpty(aspPath) && !FileUtils.FileExists(aspPath))
                messages.Add(String.Format("\"{0}\" file could not be found", aspPath));

            if (!String.IsNullOrEmpty(aspNet11Path) && !FileUtils.FileExists(aspNet11Path))
                messages.Add(String.Format("\"{0}\" file could not be found", aspNet11Path));

            if (!String.IsNullOrEmpty(aspNet20Path) && !FileUtils.FileExists(aspNet20Path))
                messages.Add(String.Format("\"{0}\" file could not be found", aspNet20Path));

			if (!String.IsNullOrEmpty(aspNet40Path) && !FileUtils.FileExists(aspNet40Path))
				messages.Add(String.Format("\"{0}\" file could not be found", aspNet40Path));

            if (!String.IsNullOrEmpty(php4Path) && !FileUtils.FileExists(php4Path))
                messages.Add(String.Format("\"{0}\" file could not be found", php4Path));

            if (!String.IsNullOrEmpty(php5Path) && !FileUtils.FileExists(php5Path))
                messages.Add(String.Format("\"{0}\" file could not be found", php5Path));

            if (!String.IsNullOrEmpty(perlPath) && !FileUtils.FileExists(perlPath))
                messages.Add(String.Format("\"{0}\" file could not be found", perlPath));

            if (!String.IsNullOrEmpty(pythonPath) && !FileUtils.FileExists(pythonPath))
                messages.Add(String.Format("\"{0}\" file could not be found", pythonPath));

            if (!String.IsNullOrEmpty(securedFoldersFilterPath) && !FileUtils.FileExists(securedFoldersFilterPath))
                messages.Add(String.Format("\"{0}\" file could not be found", securedFoldersFilterPath));

            if (!String.IsNullOrEmpty(cfscriptsdirPath) && !FileUtils.DirectoryExists(cfscriptsdirPath))
                messages.Add(String.Format("\"{0}\" directory could not be found", cfscriptsdirPath));

            if (!String.IsNullOrEmpty(cfflashdirectoryPath) && !FileUtils.DirectoryExists(cfflashdirectoryPath))
                messages.Add(String.Format("\"{0}\" directory could not be found", cfflashdirectoryPath));
            
            
            if (!String.IsNullOrEmpty(coldfusionPath) && !FileUtils.FileExists(coldfusionPath))
                messages.Add(String.Format("\"{0}\" file could not be found", coldfusionPath));
            
            return messages.ToArray();
        }
 /// <remarks/>
 public System.IAsyncResult BeginUpdateGroup(SystemGroup group, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UpdateGroup", new object[] {
                 group}, callback, asyncState);
 }
 /// <remarks/>
 public void UpdateGroupAsync(SystemGroup group, object userState)
 {
     if ((this.UpdateGroupOperationCompleted == null))
     {
         this.UpdateGroupOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateGroupOperationCompleted);
     }
     this.InvokeAsync("UpdateGroup", new object[] {
                 group}, this.UpdateGroupOperationCompleted, userState);
 }
예제 #5
0
        public static void CreateGroup(SystemGroup group, RemoteServerSettings serverSettings,
            string usersOU, string groupsOU)
        {
            try
            {
                if (serverSettings.ADEnabled)
                {
                    // AD mode
                    // root entry
					DirectoryEntry objRoot = GetGroupsRoot(serverSettings, groupsOU);

                    // add group
                    DirectoryEntry objGroup = objRoot.Children.Add("CN=" + group.Name, "group");
                    SetObjectProperty(objGroup, "description", group.Description);
                    SetObjectProperty(objGroup, "sAMAccountName", group.Name);
                    objGroup.CommitChanges();

                    // add users to group
                    foreach (string userName in group.Members)
                    {
                        //DirectoryEntry objUser = FindUserObject(userName, serverSettings, usersOU);
						DirectoryEntry objUser = GetUserObject(userName, serverSettings, usersOU);
                        if (objUser != null)
                        {
                            objGroup.Invoke("Add", new Object[] { objUser.Path.ToString() });
                            objUser.Close();
                        }
                    }

                    objGroup.Close();
                }
                else
                {
                    // LOCAL mode
                    DirectoryEntry computer = new DirectoryEntry(
                        String.Format("WinNT://{0}", Environment.MachineName));

                    // create group
                    DirectoryEntry objGroup = computer.Children.Add(group.Name, "group");
                    objGroup.Properties["Description"].Add(group.Description);

                    // save group
                    objGroup.CommitChanges();

                    // add group members
                    foreach (string user in group.Members)
                    {
                        try
                        {
                            objGroup.Invoke("Add", new object[] { String.Format("WinNT://{0}/{1},user", Environment.MachineName, user) });
                        }
                        catch { /* skip */ }
                    }

                    // save group
                    objGroup.CommitChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Could not create system group", ex);
            }
        }
 /// <remarks/>
 public void CreateGroupAsync(SystemGroup group)
 {
     this.CreateGroupAsync(group, null);
 }
 public int UpdateSharePointGroup(SystemGroup item)
 {
     object[] results = this.Invoke("UpdateSharePointGroup", new object[] {
                 item});
     return ((int)(results[0]));
 }
예제 #8
0
		/// <summary>
		/// Installs the provider.
		/// </summary>
		/// <returns>Error messsages if any specified.</returns>
		public override string[] Install()
		{
			List<string> messages = new List<string>();

			string[] cfgMsgs = webObjectsSvc.GrantConfigurationSectionAccess(INSTALL_SECTIONS_ALLOWED);
			//
			if (cfgMsgs.Length > 0)
			{
				messages.AddRange(cfgMsgs);
				return messages.ToArray();
			}

			try
			{
				SecurityUtils.EnsureOrganizationalUnitsExist(ServerSettings, UsersOU, GroupsOU);
			}
			catch (Exception ex)
			{
				Log.WriteError(ex);
				messages.Add(String.Format("Could not check/create Organizational Units: {0}", ex.Message));
				return messages.ToArray();
			}

			// Create web group name.
			if (String.IsNullOrEmpty(WebGroupName))
			{
				messages.Add("Web Group can not be blank");
			}
			else
			{
				try
				{
					// create group
					if (!SecurityUtils.GroupExists(WebGroupName, ServerSettings, GroupsOU))
					{
						SystemGroup group = new SystemGroup();
						group.Name = WebGroupName;
						group.Members = new string[] { };
						group.Description = "WebsitePanel System Group";

						SecurityUtils.CreateGroup(group, ServerSettings, UsersOU, GroupsOU);
					}
				}
				catch (Exception ex)
				{
					Log.WriteError(ex);
					messages.Add(String.Format("There was an error while adding '{0}' group: {1}",
						WebGroupName, ex.Message));
				}
			}

			// Setting up shared iisAppObject pools.
			try
			{
				WebAppPoolHelper aphl = new WebAppPoolHelper(ProviderSettings);
				// Find shared pools
				var sharedPools = Array.FindAll<WebAppPool>(aphl.SupportedAppPools.ToArray(), 
					x => aphl.isolation(x.Mode) == SiteAppPoolMode.Shared);
				//
				foreach (var item in sharedPools)
				{
					using (var srvman = webObjectsSvc.GetServerManager())
					{
						// Local variables
						bool enable32BitAppOnWin64 = (aphl.dotNetVersion(item.Mode) == SiteAppPoolMode.dotNetFramework1) ? true : false;
						//
						if (srvman.ApplicationPools[item.Name] == null)
						{
							ApplicationPool pool = srvman.ApplicationPools.Add(item.Name);
							//
							pool.ManagedRuntimeVersion = aphl.aspnet_runtime(item.Mode);
							pool.ManagedPipelineMode = aphl.runtime_pipeline(item.Mode);
							pool.ProcessModel.IdentityType = ProcessModelIdentityType.NetworkService;
							pool.AutoStart = true;
							pool.Enable32BitAppOnWin64 = enable32BitAppOnWin64;
							//
							srvman.CommitChanges();
						}
					}
				}
			}
			catch (Exception ex)
			{
				Log.WriteError(ex);
				//
				messages.Add(String.Format("There was an error while creating shared iisAppObject pools: {0}", ex.Message));
			}

			// Ensure logging settings are configured correctly on a web server level
			try
			{
				webObjectsSvc.SetWebServerDefaultLoggingSettings(LogExtFileFlags.SiteName
					| LogExtFileFlags.BytesRecv | LogExtFileFlags.BytesSent | LogExtFileFlags.Date);
			}
			catch (Exception ex)
			{
				Log.WriteError(ex);
				//
				messages.Add(String.Format(@"There was an error while configure web server's default 
					logging settings. Reason: {0}", ex.StackTrace));
			}

			// Ensure logging settings are configured correctly on a web server level
			try
			{
				webObjectsSvc.SetWebServerDefaultLoggingSettings(LogExtFileFlags.SiteName
					| LogExtFileFlags.BytesRecv | LogExtFileFlags.BytesSent | LogExtFileFlags.Date);
			}
			catch (Exception ex)
			{
				Log.WriteError(ex);
				//
				messages.Add(String.Format(@"There was an error while configure web server's default 
					logging settings. Reason: {0}", ex.StackTrace));
			}

			return messages.ToArray();
		}
 /// <remarks/>
 public void AddSharePointGroupAsync(SystemGroup item)
 {
     this.AddSharePointGroupAsync(item, null);
 }
 /// <remarks/>
 public void AddSharePointGroupAsync(SystemGroup item, object userState)
 {
     if ((this.AddSharePointGroupOperationCompleted == null))
     {
         this.AddSharePointGroupOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddSharePointGroupOperationCompleted);
     }
     this.InvokeAsync("AddSharePointGroup", new object[] {
                 item}, this.AddSharePointGroupOperationCompleted, userState);
 }
 public void UpdateGroup(SystemGroup group)
 {
     try
     {
         Log.WriteStart("'{0}' UpdateGroup", ProviderSettings.ProviderName);
         SPS.UpdateGroup(group);
         Log.WriteEnd("'{0}' UpdateGroup", ProviderSettings.ProviderName);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("'{0}' UpdateGroup", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
예제 #12
0
	    public override string[] Install()
	    {
		    List<string> messages = new List<string>();

            try
            {
                SecurityUtils.EnsureOrganizationalUnitsExist(ServerSettings, UsersOU, GroupsOU);
            }
            catch (Exception ex)
            {
                messages.Add(String.Format("Could not check/create Organizational Units: {0}", ex.Message));
                return messages.ToArray();
            }

		    // create folder if it not exists
		    if (String.IsNullOrEmpty(SiteId))
		    {
			    messages.Add("Please, select FTP site to create accounts on");
		    }
		    else
		    {
			    // create FTP group name
			    if (String.IsNullOrEmpty(FtpGroupName))
			    {
				    messages.Add("FTP Group can not be blank");
			    }
			    else
			    {
				    try
				    {
					    // create group
                        if (!SecurityUtils.GroupExists(FtpGroupName, ServerSettings, GroupsOU))
					    {
						    SystemGroup group = new SystemGroup();
                            group.Name = FtpGroupName;
						    group.Members = new string[] { };
						    group.Description = "WebsitePanel System Group";

                            SecurityUtils.CreateGroup(group, ServerSettings, UsersOU, GroupsOU);
					    }
				    }
				    catch (Exception ex)
				    {
					    messages.Add(String.Format("There was an error while adding '{0}' group: {1}",
                            FtpGroupName, ex.Message));
					    return messages.ToArray();
				    }
			    }

			    FtpSite site = GetSite(SiteId);
			    try
			    {
				    // set permissions on the site root
                    SecurityUtils.GrantNtfsPermissions(site.ContentPath, FtpGroupName,
                        NTFSPermission.Read, true, true, ServerSettings,
                        UsersOU, GroupsOU);
			    }
			    catch (Exception ex)
			    {
				    messages.Add(String.Format("Can not set permissions on '{0}' folder: {1}",
					    site.ContentPath, ex.Message));
				    return messages.ToArray();
			    }
		    }
		    return messages.ToArray();
	    }
        public static int UpdateSharePointGroup(SystemGroup item)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
            if (accountCheck < 0) return accountCheck;

            // load original meta item
            SystemGroup origItem = (SystemGroup)PackageController.GetPackageItem(item.Id);
            if (origItem == null)
                return BusinessErrorCodes.ERROR_SHAREPOINT_GROUPS_PACKAGE_ITEM_NOT_FOUND;

            // check package
            int packageCheck = SecurityContext.CheckPackage(origItem.PackageId, DemandPackage.IsActive);
            if (packageCheck < 0) return packageCheck;

            // place log record
            TaskManager.StartTask("SHAREPOINT", "UPDATE_GROUP", origItem.Name, item.Id);

            try
            {
                // get service
                SharePointServer sps = GetSharePoint(origItem.ServiceId);

                item.Description = "WebsitePanel System Group";

                // update service item
                sps.UpdateGroup(item);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
예제 #14
0
 public virtual void UpdateGroup(SystemGroup group)
 {
     SecurityUtils.UpdateGroup(group, ServerSettings, UsersOU, GroupsOU);
 }
 /// <remarks/>
 public System.IAsyncResult BeginUpdateSharePointGroup(SystemGroup item, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UpdateSharePointGroup", new object[] {
                 item}, callback, asyncState);
 }
예제 #16
0
        public override bool InstallFrontPage(string siteId, string username, string password)
        {
			// Ensure requested user account doesn't exist
			if (SecurityUtils.UserExists(username, ServerSettings, UsersOU))
				return false;
			// Ensure a web site exists
			if (!SiteExists(siteId))
				return false;
			// create user account
			SystemUser user = new SystemUser
			{
				Name = username,
				FullName = username,
				Description = "WebsitePanel System Account",
				Password = password,
				PasswordCantChange = true,
				PasswordNeverExpires = true,
				AccountDisabled = false,
				System = true,
			};

			// create in the system
			SecurityUtils.CreateUser(user, ServerSettings, UsersOU, GroupsOU);

			try
			{
				string cmdPath = null;
				string cmdArgs = null;
				//
				string m_webSiteId = webObjectsSvc.GetWebSiteIdFromIIS(siteId, null);

				// try to install FPSE2002
				// add registry key for anonymous group if not exists
				RegistryKey portsKey = Registry.LocalMachine.OpenSubKey(FRONTPAGE_ALLPORTS_REGLOC, true);
				portsKey.SetValue("anonusergroupprefix", "anonfp");

				#region Create anonymous group to get FPSE work

				string groupName = "anonfp_" + m_webSiteId;
				if (!SecurityUtils.GroupExists(groupName, ServerSettings, GroupsOU))
				{
					SystemGroup fpseGroup = new SystemGroup();
					fpseGroup.Name = groupName;
					fpseGroup.Description = "Anonymous FPSE group for " + siteId + " web site";
					fpseGroup.Members = new string[] { username };
					SecurityUtils.CreateGroup(fpseGroup, ServerSettings, UsersOU, GroupsOU);
				}

				#endregion

				#region Install FPSE 2002 to the website by owsadm.exe install command

				cmdPath = Environment.ExpandEnvironmentVariables(FPSE2002_OWSADM_PATH);
				cmdArgs = String.Format("-o install -p /LM/W3SVC/{0} -u {1}", m_webSiteId, username);
				Log.WriteInfo("Command path: " + cmdPath);
				Log.WriteInfo("Command path: " + cmdArgs);
				Log.WriteInfo("FPSE2002 Install Log: " + FileUtils.ExecuteSystemCommand(cmdPath, cmdArgs));
				
				#endregion

				#region Enable Windows Authentication mode
				
				winAuthSvc.SetEnabled(siteId, true);

				#endregion
			}
			catch (Exception ex)
			{
				Log.WriteError(ex);
				// Signal to the client installation request has been failed.
				return false;
			}

			return true;
        }
 /// <remarks/>
 public void UpdateSharePointGroupAsync(SystemGroup item)
 {
     this.UpdateSharePointGroupAsync(item, null);
 }
예제 #18
0
        public static SystemGroup GetGroup(string groupName, RemoteServerSettings serverSettings, string groupsOU)
        {
            try
            {
                if (serverSettings.ADEnabled)
                {
                    // AD mode
                    // get group entry
                    DirectoryEntry objGroup = FindGroupObject(groupName, serverSettings, groupsOU);
                    if (objGroup == null)
                        return null;

                    // fill group
                    SystemGroup group = new SystemGroup();
                    group.Name = GetObjectProperty(objGroup, "cn").ToString();
                    group.Description = GetObjectProperty(objGroup, "description").ToString();

                    // get group users
                    group.Members = GetGroupUsers(objGroup);

                    return group;
                }
                else
                {
                    // LOCAL mode

                    SystemGroup groupInfo = null;

                    DirectoryEntry computer = new DirectoryEntry(
                        String.Format("WinNT://{0}", Environment.MachineName));

                    // get group entry
                    DirectoryEntry group = computer.Children.Find(groupName, "group");

                    // get group properties
                    groupInfo = new SystemGroup();

                    groupInfo.Name = groupName;
                    groupInfo.Description = (string)group.Properties["Description"].Value;

                    // get group members
                    List<string> groupMembers = new List<string>();
                    object users = group.Invoke("Members", null);
                    foreach (object nUser in (IEnumerable)users)
                    {
                        // Get the Directory Entry.
                        DirectoryEntry objUser = new DirectoryEntry(nUser);
                        groupMembers.Add(objUser.Name);
                    }

                    groupInfo.Members = groupMembers.ToArray();

                    return groupInfo;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Could not get system group properties", ex);
            }
        }
예제 #19
0
		/// <summary>
		/// Installs Ftp7 provider.
		/// </summary>
		/// <returns>Error messages.</returns>
        public override string[] Install()
        {
            List<string> messages = new List<string>();

			FtpSite site = null;
			string folder = FileUtils.EvaluateSystemVariables(DefaultFtpSiteFolder);
			string logsDirectory = FileUtils.EvaluateSystemVariables(DefaultFtpSiteLogsFolder);
			// Create site folder.
			if (!FileUtils.DirectoryExists(folder))
			{
				FileUtils.CreateDirectory(folder);
			}
			// Create logs folder.
			if (!FileUtils.DirectoryExists(logsDirectory))
			{
				FileUtils.CreateDirectory(logsDirectory);
			}

			site = new FtpSite();

			site.Name = this.SiteId;
			site.SiteId = this.SiteId;
			site.ContentPath = DefaultFtpSiteFolder;
			site.Bindings = new ServerBinding[1];
			// set default log directory
			site.LogFileDirectory = DefaultFtpSiteLogsFolder;
			// set default logging fields
			site[FtpSite.MSFTP7_LOG_EXT_FILE_FIELDS] = DEFAULT_LOG_EXT_FILE_FIELDS;

			if (!String.IsNullOrEmpty(this.SharedIP))
			{
				site.Bindings[0] = new ServerBinding(this.SharedIP, "21", String.Empty);
			}
			else
			{
				site.Bindings[0] = new ServerBinding("*", "21", "*");
				//// Get information on local server.
				//IPHostEntry localServerHostEntry = Dns.GetHostEntry(Dns.GetHostName());
				//foreach (IPAddress address in localServerHostEntry.AddressList)
				//{
				//    if (address.AddressFamily == AddressFamily.InterNetwork)
				//    {
				//        site.Bindings[0] = new ServerBinding(address.ToString(), "21", String.Empty);
				//    }
				//}
			}

			if (this.IsFtpServerBindingsInUse(site))
			{
				messages.Add("Cannot create ftp site because requested bindings are already in use.");
				return messages.ToArray();
			}

            try
            {
                SecurityUtils.EnsureOrganizationalUnitsExist(ServerSettings, UsersOU, GroupsOU);
            }
            catch (Exception ex)
            {
                messages.Add(String.Format("Could not check/create Organizational Units: {0}", ex.Message));
                return messages.ToArray();
            }

            // create folder if it not exists
            if (String.IsNullOrEmpty(SiteId))
            {
                messages.Add("Please, select FTP site to create accounts on");
            }
            else
            {
                // create FTP group name
                if (String.IsNullOrEmpty(FtpGroupName))
                {
                    messages.Add("FTP Group can not be blank");
                }
                else
                {
                    try
                    {
                        // create group
                        if (!SecurityUtils.GroupExists(FtpGroupName, ServerSettings, GroupsOU))
                        {
                            SystemGroup group = new SystemGroup();
                            group.Name = FtpGroupName;
                            group.Members = new string[] { };
                            group.Description = "WebsitePanel System Group";

                            SecurityUtils.CreateGroup(group, ServerSettings, UsersOU, GroupsOU);
                        }
                    }
                    catch (Exception ex)
                    {
                        messages.Add(String.Format("There was an error while adding '{0}' group: {1}",
                            FtpGroupName, ex.Message));
                        return messages.ToArray();
                    }
                }

            	if (!this.ftpSitesService.SiteExists(this.SiteId))
				{
						this.CreateSite(site);
				}
				else
				{
					this.UpdateSite(site);
				}
            	
                try
                {
                    // set permissions on the site root
					SecurityUtils.GrantNtfsPermissions(site.ContentPath, FtpGroupName,
						NTFSPermission.Read, true, true, ServerSettings,
						UsersOU, GroupsOU);
                }
                catch (Exception ex)
                {
                    messages.Add(String.Format("Can not set permissions on '{0}' folder: {1}",
                        site.ContentPath, ex.Message));
                    return messages.ToArray();
                }
            }
            return messages.ToArray();
        }
예제 #20
0
        public static void UpdateGroup(SystemGroup group, RemoteServerSettings serverSettings,
            string usersOU, string groupsOU)
        {
            try
            {
                if (serverSettings.ADEnabled)
                {
                    // AD mode
                    DirectoryEntry objGroup = FindGroupObject(group.Name, serverSettings, groupsOU);

                    if (objGroup == null)
                        return;

                    // update group properties
                    objGroup.Properties["description"].Value = group.Description;
                    objGroup.CommitChanges();

                    // remove all users from the group
                    string[] groupUsers = GetGroupUsers(objGroup);
                    foreach (string userName in groupUsers)
                    {
                        //DirectoryEntry objUser = FindUserObject(userName, serverSettings, usersOU);
						DirectoryEntry objUser = GetUserObject(userName, serverSettings, usersOU);
                        if (objUser != null)
                        {
                            objGroup.Invoke("Remove", new Object[] { objUser.Path.ToString() });
                            objUser.Close();
                        }
                    }

                    // add users to group
                    foreach (string userName in group.Members)
                    {
                        //DirectoryEntry objUser = FindUserObject(userName, serverSettings, usersOU);
						DirectoryEntry objUser = GetUserObject(userName, serverSettings, usersOU);
                        if (objUser != null)
                        {
                            objGroup.Invoke("Add", new Object[] { objUser.Path.ToString() });
                            objUser.Close();
                        }
                    }

                    objGroup.Close();
                }
                else
                {
                    // LOCAL mode
                    DirectoryEntry computer = new DirectoryEntry(
                        String.Format("WinNT://{0}", Environment.MachineName));

                    // get group entry
                    DirectoryEntry objGroup = computer.Children.Find(group.Name, "group");

                    // change group
                    objGroup.Properties["Description"].Add(group.Description);

                    // save group
                    objGroup.CommitChanges();

                    // remove all group members
                    object users = objGroup.Invoke("Members", null);
                    foreach (object nUser in (IEnumerable)users)
                    {
                        DirectoryEntry objUser = new DirectoryEntry(nUser);
                        objGroup.Invoke("Remove", new object[] { objUser.Path });
                    }

                    // add required group members
                    foreach (string user in group.Members)
                    {
                        try
                        {
                            objGroup.Invoke("Add", new object[] { String.Format("WinNT://{0}/{1},user", Environment.MachineName, user) });
                        }
                        catch { /* skip */ }
                    }

                    // save group
                    objGroup.Close();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Could not update system group", ex);
            }
        }
 public int AddSharePointGroup(SystemGroup item)
 {
     return SharePointServerController.AddSharePointGroup(item);
 }
예제 #22
0
 public void UpdateGroup(SystemGroup group)
 {
     this.Invoke("UpdateGroup", new object[] {
                 group});
 }
 public int UpdateSharePointGroup(SystemGroup item)
 {
     return SharePointServerController.UpdateSharePointGroup(item);
 }
예제 #24
0
 /// <remarks/>
 public void UpdateGroupAsync(SystemGroup group)
 {
     this.UpdateGroupAsync(group, null);
 }
예제 #25
0
        public virtual bool InstallFrontPage(string siteId, string username, string password)
        {
            if (SecurityUtils.UserExists(username, ServerSettings, UsersOU))
                return false;

            // create user account
            SystemUser user = new SystemUser();
            user.Name = username;
            user.FullName = username;
            user.Description = "WebsitePanel System Account";
            user.Password = password;
            user.PasswordCantChange = true;
            user.PasswordNeverExpires = true;
            user.AccountDisabled = false;
            user.System = true;

            // create in the system
            SecurityUtils.CreateUser(user, ServerSettings, UsersOU, GroupsOU);

            string cmdPath = null;
            string cmdArgs = null;

            // try to install FPSE2002 first
            if (IsFrontPage2002Installed())
            {
                // add registry key for anonymous group if not exists
                RegistryKey portsKey = Registry.LocalMachine.OpenSubKey(FRONTPAGE_ALLPORTS_REGLOC, true) ??
                                       Registry.LocalMachine.OpenSubKey(FRONTPAGE_ALLPORTS_REGLOC_X64, true);

                if (portsKey != null) portsKey.SetValue("anonusergroupprefix", "anonfp");

                // create anonymous group
                string groupName = "anonfp_" + siteId.Substring(siteId.IndexOf("/") + 1);

                int numberOfatempts = 0;

                while (!SecurityUtils.GroupExists(groupName, ServerSettings, GroupsOU) && numberOfatempts < 5)
                {
                    SystemGroup fpseGroup = new SystemGroup();
                    fpseGroup.Name = groupName;
                    fpseGroup.Description = "Anonymous FPSE group for " + siteId + " web site";
                    fpseGroup.Members = new string[] { username };
                    SecurityUtils.CreateGroup(fpseGroup, ServerSettings, UsersOU, GroupsOU);
                    numberOfatempts++;
                }

                // install FPSE 2002
                RegistryKey fpKey = Registry.LocalMachine.OpenSubKey(FRONTPAGE_2002_REGLOC) ??
                                    Registry.LocalMachine.OpenSubKey(FRONTPAGE_2002_REGLOC_X64);

                if (fpKey != null)
                {
                    string location = (string)fpKey.GetValue("Location");
                    cmdPath = location + @"\bin\owsadm.exe";
                }
                cmdArgs = String.Format("-o install -p /LM/{0} -type msiis -u {1}",
                    siteId, username);
            }
            else if (IsFrontPage2000Installed())
            {
                // install FPSE 2000
                RegistryKey fpKey = Registry.LocalMachine.OpenSubKey(FRONTPAGE_2000_REGLOC) ??
                                   Registry.LocalMachine.OpenSubKey(FRONTPAGE_2000_REGLOC_X64);

                if (fpKey != null)
                {
                    string location = (string)fpKey.GetValue("Location");
                    cmdPath = location + @"\bin\fpsrvadm.exe";
                }
                cmdArgs = String.Format("-o install -p /LM/{0} -type msiis -u {1}",
                    siteId, username);
            }

            if (cmdPath != null)
            {
                // launch system process
                string result = FileUtils.ExecuteSystemCommand(cmdPath, cmdArgs);
            }

            // update web site
            WebSite site = GetSite(siteId);
            if (site != null)
            {
                site.EnableWindowsAuthentication = true;
                UpdateSite(site);
            }

            return true;
        }
        private void SaveItem()
        {
            if (!Page.IsValid)
                return;

            // get form data
            SystemGroup item = new SystemGroup();
            item.Id = PanelRequest.ItemID;
            item.PackageId = PanelSecurity.PackageId;
            item.Name = usernameControl.Text;

            List<string> members = new List<string>();
            foreach (ListItem li in dlUsers.Items)
            {
                if (li.Selected)
                    members.Add(li.Value);
            }
            item.Members = members.ToArray();

            if (PanelRequest.ItemID == 0)
            {
                // new item
                try
                {
                    int result = ES.Services.SharePointServers.AddSharePointGroup(item);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("SHAREPOINT_ADD_GROUP", ex);
                    return;
                }
            }
            else
            {
                // existing item
                try
                {
                    int result = ES.Services.SharePointServers.UpdateSharePointGroup(item);
                    if (result < 0)
                    {
                        ShowResultMessage(result);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    ShowErrorMessage("SHAREPOINT_UPDATE_GROUP", ex);
                    return;
                }
            }

            // return
            RedirectSpaceHomePage();
        }
        public void ImportItem(int packageId, int itemTypeId, Type itemType,
			ResourceGroupInfo group, string itemName)
        {
            // get service id
            int serviceId = PackageController.GetPackageServiceId(packageId, group.GroupName);
            if (serviceId == 0)
                return;

            if (itemType == typeof(SystemUser))
            {
                // import user
                SystemUser user = new SystemUser();
                user.ServiceId = serviceId;
                user.PackageId = packageId;
                user.Name = itemName;
                user.Password = "";
                user.GroupName = group.GroupName;
                PackageController.AddPackageItem(user);
            }
            else if (itemType == typeof(SystemGroup))
            {
                // import group
                SystemGroup spGroup = new SystemGroup();
                spGroup.ServiceId = serviceId;
                spGroup.PackageId = packageId;
                spGroup.Name = itemName;
                spGroup.GroupName = group.GroupName;
                PackageController.AddPackageItem(spGroup);
            }
        }