Add User To "User Manager" In NT


i like to be able to add a user with the name "AdminALL" and set him into Administrator Groub, how can i do this? i start on 50 points and for complete answer i will raise upto ?

Thanks in advance
Lulli
lulliAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
hello,
i have a set of nt components (with source)that should be able to do thi ,leave your email address and i send them(i cant remember website where i found them)
+you get alot of other helpful nt comps in this package.
contains comps like NtAddUser,NtAddGlobalUser etc..
Regards Barry

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lulliAuthor Commented:

maybe i have to add the user to the administrator group on the fly, my email is lulli@vis.is
0
intheCommented:
ok am sending in a couple of minute
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

lulliAuthor Commented:
I get error on NTADDLocalMember.pas , i'm using Delphi 4.0
C/S
0
intheCommented:
i am going out for a while but leave the error message here and i say what is wrong,i also installed them in delphi4 c/s .are you installing them on nt?
i didnt install them all only some so i have a look when i get back.
0
lulliAuthor Commented:
alright, i have install theese components unless "NTADDLocalMember.pas" and i can't add user with "NTAddUser???" component , nothing works
0
lulliAuthor Commented:
alright, i have install theese components unless "NTADDLocalMember.pas" and i can't add user with "NTAddUser???" component , nothing works
0
intheCommented:
hi
i find better ones(not installable components but units) that contain the nt functions you need here:
http://members.xoom.com/_XMCM/ray_adams/files/LM.ZIP
see the following functions declared in
lmacess.pas in this zip,just add this unit and any others it needs to your uses section then call the function you need.

functions include:

function NetGroupAdd (serverName : PWideChar; level : Integer; buffer : PChar; var parm_err : Integer) : NetAPIStatus; stdcall;

function NetGroupAddUser (serverName, GroupName, UserName : PWideChar) : NetAPIStatus; stdcall;

function NetGroupDelUser (serverName, groupName, userName : PWideChar) : NetAPIStatus; stdcall;

function NetLocalGroupAdd (serverName : PWideChar; level : Integer; buffer : PChar; var parm_err : Integer) : NetAPIStatus; stdcall;

function NetLocalGroupAddMember (serverName, groupName : PWideChar; memberSid : PSID) : NetAPIStatus; stdcall;
0
intheCommented:
note:
 do you have registry access(admin access?)you will need this to create users etc..probably why it was failing before.
or
you can get around having to be the admin by using this TNTRegistry unit from:
http://www.maxoutput.com/ 

0
lulliAuthor Commented:
I'am adminitrator
0
lulliAuthor Commented:
I'am adminitrator
0
lulliAuthor Commented:
I can't install theese component from
                                                    http://www.maxoutput.com/ 

I'm using Delphi 4.0, and

if RegEnumKeyEx(DeleteKey, I, PChar(KeyName), Len, nil, nil, nil, nil) = ERROR_SUCCESS then

Error = type of actual parameter?????????????
0
lulliAuthor Commented:
Barry!!!!!!
0
intheCommented:
hi,
sorry make you wait i been asleep.

you dont need the registry component as you are the admin,it is for people who are not admins to have more rights in reading/writing the registry
excerpt from page:
"
TNTRegistry is a Delphi 3.0 component which replaces Borland's built-in TRegistry component.   It fixes the bug in TRegistry which prevents NON-administrative users from modifying the system registry from under Windows NT.  
                                     "
i see it doesnt come with source code but tht dont matter i can paste a free version here if you want it.as there are some on dejanews.

the errors are because it was made for delphi3 ,in delphi4 youd need to change some of the variables from integers to cardinals etc..(but you cant as you dont have the source.)
did you try the lm.zip files?
do they work?
0
lulliAuthor Commented:
i get error on this " "

function NetGroupAdd (serverName : PWideChar; "level : Integer;" "buffer : PChar;" "var parm_err : Integer") : NetAPIStatus; stdcall;

Theese three in the function, what is that value e.g
"var parm_err : integer"

now on the TRegistry, you may send me "palli@vis.is"

i have administrator rights, but i'm buiding program for non administrator that have to write values to registry, but how?
0
lulliAuthor Commented:
do you have any example for "RegCreateKeyEx" API? and
ALL_KEY_ACCESS
0
intheCommented:
hi,
basically the parm_err can be a 0 or a
var
 d : dword;

then use the d in parm_err.

the functions from these files are all documented in win32.hlp file in you delphi directory(do a search on your pc for win32.hlp probably under "borland shared" dir)
using the find of this help you will see
the following:

(special note the security requirements)

The NetGroupAdd function creates a global group in the security database.

Security Requirements

Only members of the Administrators or Account Operators local group can successfully execute NetGroupAdd.

NET_API_STATUS NetGroupAdd(

    LPWSTR servername,      
    DWORD level,      
    LPBYTE buf,      
    LPDWORD parm_err       
   );      
 

Parameters

servername

Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer.

level

Specifies one of the following values to set the level of information pointed to in the buf parameter.

Value      Meaning
0      Specify group name. The buf parameter contains a pointer to a GROUP_INFO_0 structure.
1      Specify group name and a comment. The buf parameter contains a pointer to a GROUP_INFO_1 structure.
2      Specifies information about the group. The buf parameter contains a pointer to a GROUP_INFO_2 structure.
 

buf

Pointer to a buffer containing the global group information structure.

parm_err

Optional pointer to a DWORD to return the index of the first parameter in error when ERROR_INVALID_PARAMETER is returned. If NULL, the parameter is not returned on error.


now the registry problem i am blind i didnt see te link to the source code:
http://www.maxoutput.com/ntreg.pas
you will definelty need this if your writing to the registry and not the admin.
rememeber any problems on using it you may need change integers to cardinals etc.
il try find an example of RegCreateKeyEx
0
intheCommented:
couple of examples i found:

example1:

procedure TForm1.Button1Click(Sender: TObject);
var a:Hkey;
begin
RegCreateKeyEx(HKEY_LOCAL_MACHINE,'Klop',0,'',REG_OPTION_NON_VOLATILE,   KEY_ALL_ACCESS,nil,a,nil);
end;

example 2:

Function TForm1.ReadFromRegistry:DWord;
Var
  Res:Boolean;
  TempKey: HKey;
  TempKeyStr:Pchar;
  Disposition: Integer;
  Dtype:Integer;
  Dsize:Integer;
  RegData:DWORD;
Begin
  Dtype:=REG_BINARY;
  Dsize:=SizeOf(DWORD);
  TempKeyStr:=PChar('System\CurrentControlSet\Services\VxD\EL_I2C');   Res:=RegCreateKeyEx(HKEY_LOCAL_MACHINE,TempKeyStr, 0 ,nil,
                      REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,nil,                       TempKey,@Disposition) = ERROR_SUCCESS;
  if Disposition = REG_CREATED_NEW_KEY then
 
Res:=RegOpenKeyEx(HKEY_CLASSES_ROOT,TempKeyStr,0,KEY_ALL_ACCESS,TempKey) = ERROR_SUCCESS;
  res:=RegQueryValueEx(TempKey,'IO_BASE',nil,@Dtype,@RegData,@DSize) =ERROR_SUCCESS;
  RegCloseKey(TempKey);
  if not res then RegData:=$305;
  Result:=RegData;
End;

hope they help ;-)

0
lulliAuthor Commented:
Can you fix for me NTReg.pas ?
0
intheCommented:
sure ,ill take a look but not till tommorrow (im exhausted after very long day at work ;-(

ill post something tommorrow night (probably about 24 hrs time from when i place this comment as cant acess internet from work at moment )
0
intheCommented:
ok fixed :-)


the easy way open a new blank project in delphi and add ntreg to the uses  ,press f9 to compile and it will give error so click ok and scroll up a couple of lines to where "Len" is declared and all you have to do is replace these lines:

var
I,Len : Integer;
   
with

var
I : Integer;
Len: Cardinal;

press f9 again to compile and go to next error line.
this occurs in about 6 places the change is needed.

Regards Barry
0
lulliAuthor Commented:
i build a user on my computer that don't have administrator's rights, and when i try to create key under,
HKEY_LOCAL_MACHINE, came an error 'Can't Create Key', i'am administrator and i can write it. What's wrong with this TNTRegistry?
0
intheCommented:
are you saying that you log on as  administrator and you code didnt work.

can you paste here the code you tried so i can test it.
as long as you are admin all functions should work but when your not admin it depends,tntregisry doesnt give non admins full access just fixes some bugs with createkey ,key_all_access etc.
 
0
lulliAuthor Commented:
Var Reg : TRegistry;
begin
Reg.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE;
Reg.OpenKey('CLONE',True);
Try
Reg.CreateKey('Lulli');
Except
Begin
ShowMessage('Cant Create Key');
End;
Reg.CloseKey;
Reg.Free;
End;
0
intheCommented:
ntreg lets you create keys etc when not admin but it doesnt let you create them under HKEY_LOCAL_MACHINE.
this is for nts security reasons.
you can create them under hkey_current_user etc though instead.

uses ntreg;

procedure TForm1.Button1Click(Sender: TObject);
Var Reg : TNTRegistry;
begin
REG := TNTRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
with reg do try
openKey('Software',True);
CreateKey('Lulli');
except
ShowMessage('Cant Create Key');
Reg.CloseKey;
Reg.Free;
End;
end;


i understand d5 has a new createkey function that you can call like:
reg:= tregistry.createkey(KEY_ALL_ACCESS);
but that wont help now..
0
lulliAuthor Commented:
Thanks "Inthe"
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.