Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get login count in Confluence?

Rumceisz June 13, 2012

Hi All,

can you please suggest?

Thanks in advance!

Rumi

6 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

Try this macro

Septa Cahyadiputra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

Amazing macro, just know this macro existed.

Thanks for sharing

Rumceisz June 13, 2012

Hi,

thanks for the macro.

But I get NEver logged in for everybody!!

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

What version of Confluence you using ?

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

can you try to replace the 30th line of the above macro with the below line

#if (!$loginManager.getLoginInfo($user.name).lastSuccessfulLoginDate)
Rumceisz June 13, 2012

Hi Mizan,

I use 3.5.13

Rumceisz June 13, 2012

Hi Mizan,

I replaced the line, but the 'Last successful login' is still empty.

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

Does the macro work after doing the above changes , most probably it will work because for jira 3.5 getLoginInfo() requires string as a argument .

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

is there any difference in the output after editing the macro ? or its the same ?

even replace $user with $user.name in the else clause

Rumceisz June 13, 2012

Great work, Mizan!

Now it displays all the last login info.

The results are very strange for us: from 1995 users 1120 never logged in. Can this macro fail? I mean for example an upgrade happened in the meantime and does it register the data before upgrade or server restart?

Thanks again! Nice macro!

Rumi

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

The macro is correct as it has helped others , its written by Andrew Frayling . I dont think the upgrade has affected your output .

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

Glad people are finding the macro useful, credit to Remo Siegwart though for his answer to this question.

I doubt an upgrade or restart would affect the data, but it might be affected if the user repository changes. It uses standard API calls and I can see how the data may potentially be reset if you did something like remove a user repository and configure Confluence to use a different one as the old data may not exist, or the API call may not look for it. I've never tested it against that set of circumstances though.

Andrew.

Rumceisz June 17, 2012

Hi,

Now it doesn't work! The page where we put the macro loading for 4-5 minutes and then timeout. What could happen?

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2012

have you upgraded your Confluence ?

Rumceisz June 17, 2012

Yes, we already upgraded on friday to version 4.2.

The macro worked on friday, however it was very long time to load. Today it gets timepot everytime we refresh: after 4-5 minutes of loading.

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2012

Thats a strange behavior , you should try the macro provided in this blog instead of the one which we modified for ver 3.5 .

Rumceisz June 17, 2012

I replaced the code, but it's still veryslow and timeout. And I fear that whenever I run this macro, the whole Confluence is very slow. Can it be? Many of my customers complained today that Confluence is very slow.

Can it be this slowly loading because of the 2000 users?

Rumceisz June 17, 2012

I fear that this macro eats the memory of the whole Confluence instance!!!

Can you please confirm?

Rumceisz June 17, 2012

hi,

I can confirm that this macro cause the problem: we checked the log!!

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2012

This might be because of the number of users and a nested if-else inside the macro , you can try the query provided by Septa

SELECT u.user_name, u.first_name, u.last_name, u.created_date
FROM cwd_user u
JOIN logininfo l
ON u.user_name=l.username
WHERE l.successdate > '2011-12-31';

Rumceisz June 17, 2012

UNfortunately the SQl didn't work last time, this is why we would like to use the macro. Can these nested if-else be workarounded?

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2012

No they are needed , going with the sql will be a better option since you have 2000 users (and performance issues when you use this macro) , did you try the sql after upgrading to 4.2 ?

venkat Muppidi October 27, 2016

hi every

where to run above query provided by septa

0 votes
venkat Muppidi October 27, 2016

hi every one

what is macro

where to run

 

plase help me

0 votes
Rumceisz June 14, 2012

Still works on 4.2 too: it's OK.

0 votes
Rumceisz June 14, 2012

Hi Mizan, hi Septa,

the macro works great, only backlash that it's a bit slow due to the 2000 users.

I would like to ask you what about the Last login macro/feature on 4.2 Confluence version? We upgrade the Confluence this weekend (I just learned the info), so from sunday we will use 4.2.

Our developer colleague said that the macro won't work on the upgraded version. But you suggested a feature first which was for 4+ version?

0 votes
Septa Cahyadiputra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

Yes you can !

Here is the query for users that login after specific date. Please noted that the date is using epoch. You can convert it here

SELECT u.user_name, u.first_name, u.last_name,  d.directory_name, u.created_date  FROM cwd_user u JOIN cwd_user_attribute l ON u.id=l.user_id JOIN cwd_directory d ON u.directory_id=d.id WHERE l.attribute_value > '1338422400' AND l.attribute_name='lastAuthenticated';

Here is the query for user that never login into Confluence

SELECT u.user_name, u.first_name, u.last_name, d.directory_name, u.created_date FROM cwd_user u JOIN cwd_directory d ON u.directory_id=d.id WHERE NOT EXISTS (SELECT a.user_id FROM cwd_user_attribute a  WHERE u.id = a.user_id);

Hope it helps.

Cheers,
Septa Cahyadiputra

Septa Cahyadiputra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

Does this helps? Let me know if you need anything

Rumceisz June 13, 2012

Thank you very much!

I opt the second select. Hope that helps, le'ts see!

Septa Cahyadiputra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

Just want to inform you that I add directory_name value to avoid confusion as there is a possiblity that the user that never try to log-in are registered under a different directory.

Rumceisz June 13, 2012

Maybe this is why I got all the users as result?

We use common user management in Jira and Confluence. We create the user account in Jira which synchronize in every hour to Confluence.

Rumceisz June 13, 2012

Hi Septa,

the second select gives all the users as result! 2331 users. Some condition missing maybe?

Septa Cahyadiputra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

It seems to be the case. I have confirmed again to ensure that the given query is valid. The latest query that provided the directory name would give you a much better idea on the origin of the users.

0 votes
Septa Cahyadiputra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

Hi Rumi,

Judging from your question I assume you would like to know how many failed login attemp recorded. You could do this by two method, from database

SELECT u.user_name, a.attribute_value as FailedLogin FROM cwd_user_attribute a join cwd_user u ON a.user_id=u.id WHERE attribute_name='invalidPasswordAttempts';

This will return the username and how many failed login attempt registered on the database.

It also possible to get it using REST end point as describe here, you might want to double check the parameter but I think it should be the same with Confluence.

Hope it helps.

Cheers,
Septa Cahyadiputra

Rumceisz June 13, 2012

Hi Septa,

no, in our case we would like to remove those users that never had logged into Confluence. So we need the list those users whose login count=zero.

Can you suggest?

Many thanks,

Rumi

Septa Cahyadiputra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

Even though you already got your answer as I believe using the macro is much easier, just want to add couple of SQL that might help. Here is to get the list of users that never authenticate agains Confluence:

SELECT u.user_name, u.first_name, u.last_name, u.created_date FROM cwd_user u 

WHERE NOT EXISTS (SELECT a.username FROM logininfo a  WHERE u.user_name = a.username);

Here is the SQL query to get the list of user that never successfully login after a specific date The

SELECT u.user_name, u.first_name, u.last_name, u.created_date
FROM cwd_user u
JOIN logininfo l
ON u.user_name=l.username
WHERE l.successdate > '2011-12-31';

above query will get you the list of users that last successful login is 31st of December 2011.

Hope it helps.

Cheers,
Septa Cahyadiputra

Septa Cahyadiputra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2012

Ah, that means you are not on Confluence 4.x yet. May I know which version of Confluence you are on?

Rumceisz June 13, 2012

Hi,

many thanks for the select.

The only problem in our side that we don't have a table logininfo.

Rumceisz June 13, 2012

Septa,

sorry! I didn't mention: we have 3.5.13 version.

Could we hope? Is there a different table for logininfo?

Thanks,

Rumi

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events