How to register users and get all registered users?

I didn’t find where to ask this question, so I’m posting it in General Help.
I’m developing a simple voip application in .NET. I have Asterisk installed and FreePBX. I need to add new users programmatically(softphone checks if he is registered, if not, registers itself(optionally - creates an extension), and after that makes SIP registration). And I also need to get the list of all registered users(to make something like phonebook). I googled, but didn’t find how I can implement this functionality. Closest option is using FreePBX database, but I don’t know how to connect to it. What is the best way to do it? And is it possible?
I asked this in asterisk community, and they send me here.

Is your app running on the server, or is it a client app?

The answer will radically change the possible answers. I doubt a lot of people will help till we know.

It is a client app, it will run in same local network with server. I created test user with extension in FreePBX, and app is registering itself on start(via SIP). I want to receive id and secret from some source on start, create user in FreePBX(check, if user already exists do nothing) and only then register via SIP. Another thing I want to do is get user list with names and numbers, like in phonebook.
P.S. Sorry if I couldn’t express myself clearly, I’m not a native English speaker and know very little about Asterisk and FreePBX.

The problem you are going to have is that, if you can access that information from an unregistered phone, so can toll-call thieves.

Your best bet would be to look at the “Asterisk ARI” interface and see what that can do for you.

You should be able to parse that information via a RESTful API call. I think the default HTTPS port is 2443 and there is a separate username and password for that functionality.

Regarding security, if the APP is on your local network you can easily restrict access to it based on IP.