Is there a way in the DB of confluence to get the number of users which have been imported via Active Directory? Like searching for a tag which identifies if a user has been imported or created on the site.
I believe you can run following query against your database:
select u.id, u.user_name, u.active from cwd_user u
join cwd_membership m on u.id=m.child_user_id join cwd_group g on m.parent_id=g.id join cwd_directory d on d.id=g.directory_id
where d.directory_name='<External_Directory_Name>;
Replace the with the name of your External User Directory. If you don't know the name maybe you can take it from following:
select * from CWD_Directory
Related
I have a TYPO3 v10 instance. The felogin Extension is installed to manage 4000 users in 100 usergroups, lots of tiny projects.
Is there a feature, a trick, an extension to answer this question, while working in the backend:
For a given frontenduser-group what are the feusers that belong to that group?
There does not seem to be a way to display this in the backend. At least not in the "List" module, after clicking on any frontendgroup-name, then working in any of the standard tabs "
General / Options / Access / Notes / Extended"
Right now I get along with SQL statements like
SELECT * FROM fe_users WHERE usergroup like '%261%';
but this is very inconvenient.
I have migrated the users and groups from one old TYPO3 instance to a newer one, and now I want to enable editors to cross-check and review group memberships themselves.
The Stackoverflow "Similar questions" text-analysis tool points out that my question is indeed similar to this one: Extbase fe_user findByUsergroup - but that question is 4 Years old, and perhaps there has been some progress?
I know of such "included" feature. The listview offers a "ref" (references) column which shows you all references to this group. this might help a bit. but contains pages, content elements... and user records in a mix.
Another option is the export a CSV of the website users with the "Groups, column enabled. This should give them all the data to review the group memberships.
If that is not enough, I would create an custom module to create such a view.
Meanwhile, as a workaround, I have used a nonstandard-SQL feature, the group_concat() function, to copy all frontendusernames of each group into the (empty) "description" field of the fe_groups table.
There they form a comma-separated list. A screenshot illustrates what my backend panel now looks like. See first line:
This method is only feasible of you are running a one-off migration, or if you can practice on a staging server first. You need to have absolute control over the TYPO3 database, and your bosses and editors shouldn't mind and like the final result. Also it overwrites what is in the description column.
Also, frontendusers who are in two or more groups will NOT get added to the csv-lists! Because their usergroupcolumn has values like 262,398 which cannot be INNER JOINed properly with fe_group.uid.
The key benefit of the group_concat() method is that a single SQL UPDATE statement (almost) solves the problem. No custom PHP programming needed.
/* works on mariadb:10.3 */
UPDATE
fe_groups g,
(
SELECT
usergroup,
GROUP_CONCAT(
u.username
ORDER BY
username SEPARATOR ', '
) AS 'usernames'
from
fe_users u
where
usergroup not like '%,%'
group by
usergroup
) AS user_lookup
SET
g.description = user_lookup.usernames
WHERE
user_lookup.usergroup = g.uid
and user_lookup.usergroup not like '%,%';
The code above does not work on mysql 5.7. There I had to try this instead:
/* works on mysql 5-7 */
SET
session group_concat_max_len = 15000;
create temporary table fe_groups_extrainfo
SELECT
usergroup,
GROUP_CONCAT(
u.username
ORDER BY
username SEPARATOR ', '
) AS 'usernames'
from
fe_users u
where
usergroup not like '%,% and uid > 9'
group by
usergroup
limit
0;
insert into
fe_groups_extrainfo
SELECT
usergroup,
GROUP_CONCAT(
u.username
ORDER BY
username SEPARATOR ', '
) AS 'usernames'
from
fe_users u
where
usergroup not like '%,%'
group by
usergroup;
update
fe_groups g
inner join fe_groups_extrainfo x on g.uid = x.usergroup
set
g.description = x.usernames;
Sorry it is not a single SQL Statement as the mariadb-SQL statement but still simpler as programming a custom TYPO3 extension with a complex backend module.
Update 09/2022:
It is essential to update the TYPO3 Reference Index after using this method (direct db-access with SQL-UPDATE statements).
typo3cms referenceindex:update
Otherwise the "Ref" column in the "List" module view would still show a "-" (meaning 0) users belong in this feuser-group. After updating the refindex the "[Ref]" column will then display the approximate count of feusers.
I have made the following query:
SELECT pa.attrvalue, pa.attrname
FROM jiprofileattribute pa, jiuser u
WHERE pa.principalobjectclass = 'com.jaspersoft.jasperserver.api.metadata.user.domain.impl.hibernate.RepoUser' AND pa.principalobjectid = u.id AND
ORDER BY pa.attrname
The problem is that it returns all the attributes of all the users, and I need them to be from the respective user, I am using the community jasperserver so using tenantid is not an option for me, is there any trick to achieve this?
I am getting into Supabase and to practice I am making a suuuper simplified website-builder.
However I am having troubles with the row-level-security policies.
I have three tables:
user → with users' information like first name, last name, etc.
website → all websites
user_website → Contains the information which website belongs to which person (since a website can be owned/editted by multiple users)
user
user_id
...
website
website_id
...
user_website
user_id
website_id
user_role
...
I didn't find any useful resource, because honestly I still lack the knowledge to know how to search properly for what I need.
I only found simple expressions like (uid() = user_id), but since the "permissions" are stored in another table, I don't know how to access that.
I used queries like the following but it didn't work as intended:
SELECT
*
FROM
user_website as uw
JOIN website as w
ON uw.website_id = w.website_id
WHERE
uw.user_id = auth.uid()
Help is much appreciated – thanks!
You could define a policy like that:
CREATE POLICY may_edit ON website
FOR UPDATE TO PUBLIC
USING (EXISTS
(SELECT 1 FROM user_website
WHERE user_website.website_id = website.website_id
AND user_website.user_id = uid()
)
);
Here, uid() is a function that returns your current user ID.
This policy will let everyone modify their own website.
I called a friend for help and he pointed out a section in the Supabase docs about "policies with joins" ... yet it still didn't work for me.
The reason was that the RLS-policy on the table website references the table user-website, which didn't allow users yet to access anything.
Solution
RLS-policy for select on website:
auth.uid() in (
select user_id from user_website
where website_id = website.website_id
)
RLS-policy for select on user-website:
auth.uid() = user_id
I have the following query using the Invantive Query Tool connecting to NMBRS.
select e.number
, es.EmployeeId
, e.displayname
, es.ParttimePercentage
, es.startdate
from Nmbrs.Employees.EmployeeSchedules es
left
outer
join Nmbrs.Employees.Employees e
on es.EmployeeId = e.id
order
by e.displayname
, es.startdate
(I want to retrieve all mutations in part-time percentage/schedule)
However Nmbrs.Employees.Employees only shows active employees. And I need that because that shows the employee ID as shown in Nmbrs.Employees.EmployeeSchedules is not the employee ID shown in the UI rather it is an internal ID.
I did notice Nmbrs.Employees.Employees has an additional where clause (as per documentation):
Additional Where Clause:
- CompanyId
- active
The following query
select * from Nmbrs.Employees.Employees where active = 1
gives an error:
Unknown identifier 'active'.
Consider one of the following: Nmbrs.Employees.Employees.PartitionID, Nmbrs.Employees.Employees.Id, Nmbrs.Employees.Employees.Number, Nmbrs.Employees.Employees.DisplayName, Employees.Employees.PartitionID, Employees.PartitionID, PartitionID, Employees.Employees.Id.
Active isn't mentioned so I don't know if that is usable.
active is a server-side filter on Nmbrs.nl. It defaults to the value "active". Don't ask me why they choose to have an API reflect the user interface; it is weird, but it is the way it is.
To retrieve all employees from one or more companies (partitions), use:
use all
select * from employeesall
OR
select * from employeesinactive
These are recent additions to the Nmbrs.nl API tables supported.
Note that the output does NOT contain whether an employee is active. When you need that too, please use a view or:
select 'active' type
, t.*
from nmbrs..employeesactive t
union all
select 'inactive' type
, t.*
from nmbrs..employeesinactive t
I want to query the number of active users out of total users who have actively used my dashboard named say ABC in Tableau? What join do I need to do on which Tables and what columns will I pull in?
Open dashboard in tableau server and click on Who has seen this view?
Here you can find all information that you need. You can also download it.
Here is the "Who has seen this View?" SQL:
SELECT DISTINCT
T271.friendly_name AS "Friendly_Name (Sys Users)",
T271.name AS "Name (Sys Users)",
SUM(T298.nviews) AS "Nviews (VW Stats)",
MAX(T298.time) AS "Time (VW Stats)",
T301.name AS "Name (WB)",
T297.name AS "Name (Views)"
FROM
views_stats T298
INNER JOIN users T290 ON T298.user_id = T290.id
INNER JOIN views T297 ON T298.view_id = T297.id
INNER JOIN workbooks T301 ON T297.workbook_id = T301.id
INNER JOIN system_users T271 ON T290.system_user_id = T271.id
GROUP BY
T271.friendly_name,
T271.name,
T301.name,
T297.name