[admin_groupassignhost]
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] .
Parameters
-group
string, required
The group to which you are assigning the host.
-host
string, required
The host you are assigning to the group.
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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
none
Newest
Most Popular