Lasso Soft Inc. > Home

[admin_groupassignhost]

Linkadmin_groupassignhost
AuthorJason Huck
CategoryAdministration
Version8.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted21 Nov 2006
Updated21 Nov 2006
More by this author...

Description

Assigns the specified host to the specified group. Requires authentication as a user with permissions on Lasso's internal db's, i.e., with [auth_admin].

Sample Usage

admin_groupassignhost(
	-group='TestGroup',
	-host='Local MySQL'
);

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define_tag(
	'groupassignhost',
	-namespace='admin_',
	-req='group',
	-req='host',
	-priority='replace',
	-description='Assigns the specified host to the specified group.'
);
	inline( -database='lasso_internal', -sql='SELECT 1');
		local('sql' = '
			SELECT id 
			FROM security_groups 
			WHERE name = \'' + #group + '\'
		');
		
		inline( -sql=#sql);
			local('groupID') = field('id');
		/inline;
		
		local('hostID') = host_id(#host);
		
		local('sql' = '
			SELECT id
			FROM security_group_host_map
			WHERE id_host = ' + #hostID + '
				AND id_group = ' + #groupID + '
		');
		
		protect;
			inline( -sql=#sql);
				if(found_count);
					local('sql' = '
						UPDATE security_group_host_map
						SET allow = \'Q\'
						WHERE id = ' + field('id') + '
					');
					
					inline( -sql=#sql); /inline;
				else;
					local('sql' = '
						INSERT INTO security_group_host_map (
							id_host,
							id_group,
							allow
						) VALUES (
							' + #hostID + ',
							' + #groupID + ',
							\'Q\'
						)
					');
					
					inline( -sql=#sql); /inline;
				/if;
			/inline;
			
			return(true);
			
			handle_error;
				return(false);
			/handle_error;
		/protect;
	/inline;
/define_tag;

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft