C# function translation help

I’ve received this bit of C# from a user and I’d like to incorporate it into the flow of a Xojo tool. I’ve performed a cursory search, but I can’t find documentation for a Registry API that models this option (adding the current user to the “Backup Operators” group)

Any Registry gurus our there willing to translate to C or native Xojo?

PrincipalContext principalContext = new PrincipalContext(ContextType.Machine) ;
GroupPrincipal groupPrincipal = GroupPrincipal.FindByIdentity(principalContext, "Backup Operators");
UserPrincipal userPrincipal = UserPrincipal. Current;

seems it is about Active Directory.
you could make a small c# command line tool in vs 2022 and call it from xojo.

1 Like

If you are wanting to query AD you can use the MBS Network Plugin and LDAPMBS. There is an example project called LDAP Test.xojo_binary_project Which I used to handle application login and Querying AD for user and group properties.

Not AD. This is a local user and local group. The commend line I’m using is:

net localgroup "Backup Operators" shortName /add

I’ve never tried to test it for local bindings. You might want to shoot a message to @Christian_Schmitz to get a solid answer.

then why not use the shell to execute it from within xojo?


Has to run with elevated permissions as “Administrator”. Using RunAs won’t work on machines where the user is using a non-password authentication method (facial recognition, pin, fingerprint, etc.)

but if you would build it in xojo, does that mean the app must run as admin?
does this c# code run with user permissions?