LDAP AUth - Logoff AD user

Hi!
I read today this post: LDAP Auth - Disabled AD Users
Great script from @anton.karlan

I’ve checked and there is one user that’s still online.
I’ve tried to force it to logoff by using this:

$body = @{
userId = $userid
message = " "
status = “offline”
}
Invoke-RestMethod -Headers $Headers “https://servername/api/v1/users.setStatus” -Method Post -Body $body -ContentType ‘application/json’

It returns Success, but it only changes the message to empty, the status remains online.

Is there a way to kill all of an specific user’s sessions on Rocket.Chat? Setting them as offline should work?
If so, how can I make it?

Hi, @vandreytrindade
What is your goal?
If you want to logoff user, you can still use deactivate script. It will force user to logoff from every sessions.

Hi, @anton.karlan
I used your script but the user is still online.
I don’t know if he left Rocket.Chat logged on on his computer or smartphone.

I can see his status on “Administration > Users > username”
And it shows “Online” as his status.

When I run this command it shows he’s online too:

Invoke-RestMethod -Headers $Headers “https://servername/api/v1/users.getStatus?username=$username” -Method Get -ContentType ‘application/json’

message status success
online True

And this command too:

$url = “https://servername/api/v1/users.info?username=” + $username
Invoke-RestMethod -Headers $Headers $url -Method Get -ContentType ‘application/json’ | fl *

user : @{_id=nhc9dcjMTmiRufxtN; createdAt=2019-05-13T16:32:19.369Z; services=; username=username; emails=System.Object; type=user; status=online; active=False; roles=System.Object; name=displayname; lastLogin=2020-05-07T18:13:10.386Z; statusConnection=online; utcOffset=-3; statusText=}
success : True

Inside Rocket.Chat:

That doesn’t happens in your environment @anton.karlan ?
Which Rocket.Chat version are you using?

No, in my environment, when user deactivated he force logoff from all his sessions and couldn’t be online.

3.1.1 for now

@anton.karlan

I’ve created a dummy user to test and it really logoff every user session.
Must be a particular problem with that user.
Anyway, thanks a lot for your time and attention.
And again, great script! :grin:

1 Like