lulli
asked on
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ok am sending in a couple of minute
ASKER
I get error on NTADDLocalMember.pas , i'm using Delphi 4.0
C/S
C/S
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.
i didnt install them all only some so i have a look when i get back.
ASKER
alright, i have install theese components unless "NTADDLocalMember.pas" and i can't add user with "NTAddUser???" component , nothing works
ASKER
alright, i have install theese components unless "NTADDLocalMember.pas" and i can't add user with "NTAddUser???" component , nothing works
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;
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;
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/
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/
ASKER
I'am adminitrator
ASKER
I'am adminitrator
ASKER
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?????????????
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?????????????
ASKER
Barry!!!!!!
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?
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?
ASKER
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?
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?
ASKER
do you have any example for "RegCreateKeyEx" API? and
ALL_KEY_ACCESS
ALL_KEY_ACCESS
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
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
couple of examples i found:
example1:
procedure TForm1.Button1Click(Sender : TObject);
var a:Hkey;
begin
RegCreateKeyEx(HKEY_LOCAL_ MACHINE,'K lop',0,'', REG_OPTION _NON_VOLAT ILE, KEY_ALL_ACCESS,nil,a,nil);
end;
example 2:
Function TForm1.ReadFromRegistry:DW ord;
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\ CurrentCon trolSet\Se rvices\VxD \EL_I2C'); Res:=RegCreateKeyEx(HKEY_L OCAL_MACHI NE,TempKey Str, 0 ,nil,
REG_OPTION_NON_VOLATILE,KE Y_ALL_ACCE SS,nil, TempKey,@Disposition) = ERROR_SUCCESS;
if Disposition = REG_CREATED_NEW_KEY then
Res:=RegOpenKeyEx(HKEY_CLA SSES_ROOT, TempKeyStr ,0,KEY_ALL _ACCESS,Te mpKey) = ERROR_SUCCESS;
res:=RegQueryValueEx(TempK ey,'IO_BAS E',nil,@Dt ype,@RegDa ta,@DSize) =ERROR_SUCCESS;
RegCloseKey(TempKey);
if not res then RegData:=$305;
Result:=RegData;
End;
hope they help ;-)
example1:
procedure TForm1.Button1Click(Sender
var a:Hkey;
begin
RegCreateKeyEx(HKEY_LOCAL_
end;
example 2:
Function TForm1.ReadFromRegistry:DW
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\
REG_OPTION_NON_VOLATILE,KE
if Disposition = REG_CREATED_NEW_KEY then
Res:=RegOpenKeyEx(HKEY_CLA
res:=RegQueryValueEx(TempK
RegCloseKey(TempKey);
if not res then RegData:=$305;
Result:=RegData;
End;
hope they help ;-)
ASKER
Can you fix for me NTReg.pas ?
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 )
ill post something tommorrow night (probably about 24 hrs time from when i place this comment as cant acess internet from work at moment )
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
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
ASKER
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?
HKEY_LOCAL_MACHINE, came an error 'Can't Create Key', i'am administrator and i can write it. What's wrong with this TNTRegistry?
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.
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.
ASKER
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;
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;
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_AL L_ACCESS);
but that wont help now..
this is for nts security reasons.
you can create them under hkey_current_user etc though instead.
uses ntreg;
procedure TForm1.Button1Click(Sender
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_AL
but that wont help now..
ASKER
Thanks "Inthe"
ASKER
maybe i have to add the user to the administrator group on the fly, my email is lulli@vis.is