[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Add User To "User Manager" In NT

Posted on 2000-01-17
26
Medium Priority
?
196 Views
Last Modified: 2010-04-06

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
0
Comment
Question by:lulli
  • 14
  • 12
26 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 200 total points
ID: 2360011
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
 

Author Comment

by:lulli
ID: 2360038

maybe i have to add the user to the administrator group on the fly, my email is lulli@vis.is
0
 
LVL 17

Expert Comment

by:inthe
ID: 2360051
ok am sending in a couple of minute
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:lulli
ID: 2360096
I get error on NTADDLocalMember.pas , i'm using Delphi 4.0
C/S
0
 
LVL 17

Expert Comment

by:inthe
ID: 2360145
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
 

Author Comment

by:lulli
ID: 2360146
alright, i have install theese components unless "NTADDLocalMember.pas" and i can't add user with "NTAddUser???" component , nothing works
0
 

Author Comment

by:lulli
ID: 2360157
alright, i have install theese components unless "NTADDLocalMember.pas" and i can't add user with "NTAddUser???" component , nothing works
0
 
LVL 17

Expert Comment

by:inthe
ID: 2361060
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
 
LVL 17

Expert Comment

by:inthe
ID: 2361072
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
 

Author Comment

by:lulli
ID: 2362113
I'am adminitrator
0
 

Author Comment

by:lulli
ID: 2362238
I'am adminitrator
0
 

Author Comment

by:lulli
ID: 2362281
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
 

Author Comment

by:lulli
ID: 2363900
Barry!!!!!!
0
 
LVL 17

Expert Comment

by:inthe
ID: 2363974
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
 

Author Comment

by:lulli
ID: 2364004
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
 

Author Comment

by:lulli
ID: 2364068
do you have any example for "RegCreateKeyEx" API? and
ALL_KEY_ACCESS
0
 
LVL 17

Expert Comment

by:inthe
ID: 2364225
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
 
LVL 17

Expert Comment

by:inthe
ID: 2364630
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
 

Author Comment

by:lulli
ID: 2367533
Can you fix for me NTReg.pas ?
0
 
LVL 17

Expert Comment

by:inthe
ID: 2368692
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
 
LVL 17

Expert Comment

by:inthe
ID: 2368987
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
 

Author Comment

by:lulli
ID: 2370631
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
 
LVL 17

Expert Comment

by:inthe
ID: 2372654
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
 

Author Comment

by:lulli
ID: 2373662
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
 
LVL 17

Expert Comment

by:inthe
ID: 2376707
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
 

Author Comment

by:lulli
ID: 2377035
Thanks "Inthe"
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question