cancel
Showing results for 
Search instead for 
Did you mean: 

Get a list of all users

PVanhoof
Champ in-the-making
Champ in-the-making

Hi,

I have following code to list all users:

users = people.getPeople(null, 0)
for (var i=0; i<users.length; i++)
{
	log = users[i].properties.userName + "\n";
	logFile.content += log; 
}

However this does not work, I get an error on the log line.

I also tried users[i].properties["userName"], but that does not work either...

image

2 ACCEPTED ANSWERS

abhinavmishra14
World-Class Innovator
World-Class Innovator

That's not a correct way. people api retruns scriptbale object so basically you get string valued nodeRefs. 

You need to have actual node object in order to access properties. 

Update the line to :

log = search.findNode(users[i]).properties.userName + "\n";

These are REST APIs you can use as well to get the same details:

V1 API: http://<host>:<port>/alfresco/api/-default-/public/alfresco/versions/1/people

Repo Api: http://<host>:<port>/alfresco/service/api/people

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View answer in original post

3 REPLIES 3

abhinavmishra14
World-Class Innovator
World-Class Innovator

That's not a correct way. people api retruns scriptbale object so basically you get string valued nodeRefs. 

You need to have actual node object in order to access properties. 

Update the line to :

log = search.findNode(users[i]).properties.userName + "\n";

These are REST APIs you can use as well to get the same details:

V1 API: http://<host>:<port>/alfresco/api/-default-/public/alfresco/versions/1/people

Repo Api: http://<host>:<port>/alfresco/service/api/people

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

Thanks!

How do I check if the user account is enabled? I tried

if (isAccountEnabled(search.findNode(users[i]).properties.userName))

but that does not work.

people.isAccountEnabled() should work: 

https://docs.huihoo.com/javadoc/alfresco/4.2/repository/org/alfresco/repo/jscript/People.html#isAcco...)

~Abhinav
(ACSCE, AWS SAA, Azure Admin)