Discussion Locked

Add user account to WinNT with a program

0 helpful
23 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Well,
Can anybody help me with that problem:
I want to add with VC,VB or VFP(FoxPro) program a user account to WinNT User Manager.
Is there a way to do this, i.e. WinAPI functions, Registry hacks, etc.
Any help - welcome, especially tech-info and program code!
Regards,
The BIG RED FOX

23 replies

by syscokid

One possibility would be to shell out of the program and run the native NT command "net user". For example,

net user / /add /domain

by kent.manley

Gee, why don't you grab a win32 api manual and a c++ compiler and get to work?

There are at least three ways I know to do this:
1) NT Resource kit adduser program
2) win32 perl with win32 extension
3) VBScript can access the objects and methods you want.

What's your motivation for avoiding the api calls?

Kent

by zlatin zlatev

Well, actually I do not have a GOOD WinAPI manual, and am learning WinAPI functions from demos, source codes and tech-infos (mail-lists, discussion boards, etc.)
I DO NOT want to use PERL, actually I want to do this from a FoxISAPI server so it will be done in Visual FoxPro code.
Almost the same is with VBScript.
I can "translate" VB/VC++ code to VFP. I have basic knowledge in VB/VC++, and I haven't found yet many programs that I do not understand what they do.

by maunteljw

If you look in the NT Resourse Kit, there is a VB Script that can accomplish that. (Useraccount.vbs) I've used this before and it did the job.

by zlatin zlatev

I have checked the VBS that you send to me... Thanks BUT...
No, this is *not* what I want to do.

This VBS just *shows* the user accounts from the NT server.
It uses some CScript classes that I DO NOT know how they work, so I cannot convert thisto a code for *ADDING* User account to the remote NT Server.

by remeltdb

The NT40 Resource Kit includes a utility called ADDUSER.EXE that I have used in the past with very good results. We were migrating from Netware to NT and did not want to use the Netware Migration Tool so I used ADDUSER.EXE to create users groups etc.

All the user names, group names etc. are stored in a separate comma-delimited file.

Regards,
Dave

by zlatin zlatev

Well, I know that this is ANOTHER question, but I have problems with creating the USER_INFO structure (as described in Visual Studio's MSDN Library) under Visual FoxPro. VFP does NOT support pointers and user defined types, so I have to trick it with Strings and WinApi functions, but maybe I'm doing something wrong, because NetAddUser does not create the user account and returns status code 53 (???) or if I call it twice it returns (on the second call) status code 124 (user already exists), butI actually do not see any new user added in user manager.
Can anybody help me with this stuff?
(I will send him/her the VFP code that I'm trying to use).

by zlatin zlatev

Tech points update...

*NOTE*
1. I have Visual Studio MSDN Library and have read it.
2. I have checked also the Online MSDN library.
3. I have the entire MS Visual Studio 6.0
(VC, VB, VFP, VID, the API Viewer that is shiped with VB, the MSDN library)
4. ***** I DO NOT Want to USE external EXEcutables

5. I know that the NetUser WinApi and the ADSI can work for me.

6. I am looking for easy way to do this from Microsoft VISUAL FOXPRO

7. I am working over that problem, so it is possible to find out the answer *without* your help

Regards,
Zlatin Zlatev

by zlatin zlatev

I have found a solution for the problem with odd status codes.
In fact I was trying to use an ASCII version of the
lstrcpy
function for "creating" pointers and that was the reason for the malfunction of the NetUserAdd
WinApi function...

Because I think that I can do this myself,
I'm going to close that question soon.

However, yet there are a lot of problems to do with - one is with the users SIDs and adding the users to Localgroups.

Best wishes,
Zlatin Zlatev,
Software Engineer and Programmer Mentor
JEI-Bulgaria

This discussion is closed to new replies.