How to add a computer to a Windows domain

I’m developing an app to semi automate the workstation deployment process on a Windows domain and have most of it worked out except the step to join the computer to the domain. Doing this in powershell is easy but I don’t see how to do this in xojo. The only method I can think of is to create a powershell script that does the joining and run it via shell.execute() but was hoping to for a xojo cmdlet that can do the joining but haven’t found one.

Does anyone know how to join a domain directly in xojo without running an external script?

EDIT:
One additional note which may or may not make a difference. We are using a Linux samba 4 server for the domain controller instead of a Windows AD server.

NetJoinDomain

It’s a pretty straight forward call if you know about Declares, see here if you need pointers, let me know if you don’t get anywhere and I’ll have a play in a VM.

In order to use declares, which I have limited experience with, you need to know all of the relevant dll calls, which I don’t. If you can point me to which dll’s and functions I need to call, I can work on testing writing the declares.

EDIT:
Oops, I didn’t see your link to the NetJoinDoman function. I’ll check it out and run some tests. Thanks