Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by Thorsten Meyer
Tue, 29 Apr 2003 16:45
User Accounts under Win2000
Author: Thorsten Meyer
Date: Tue, 29 Apr 2003 16:45
Date: Tue, 29 Apr 2003 16:45
30 lines
2058 bytes
2058 bytes
Hallo, i've designed an appliation that manage User and Groupaccounts under a Win Nt4 Domaen. This Applications runs perfectly for now 2 years. It was developed under C++ Builder 5 Prof. Now we upgraded our 6 Server to Win2000 Advance Server and normal Server as Domaen Controller with one NT4 Server as an BDC all in the 'Mixed Mode' (not the 'Native Mode' !!). At this time my application now crashed when it wants to add a new User to our Domaen. The Problem is the function netuseradd() that returns now the value 'errgroupexist' and failed to add the new user. In the application i use the function netgroupadd(), this works fine yet. I think the Problem is that the Microsoft API was upgraded ?! Is there any Update available for this LAN Manager API? regards for help Thorsten Meyer -- ************************************************* heinrich-hertz-berufskolleg der Stadt Bonn Dipl.-Ing. Thorsten Meyer, StR Herselerstr. 1-5 53117 Bonn Dienst Tel. 0228 777000 Priv. Tel. 02224 981203 *************************************************
Re: User Accounts under Win2000
Author: Vladimir Afanasyev
Date: Wed, 30 Apr 2003 07:05
Date: Wed, 30 Apr 2003 07:05
98 lines
4238 bytes
4238 bytes
Hi Thorsten,
It is my answer for similar question:Hi,
"Fernando" <ferjat@terra.es> wrote:
>Thank you, but SVC it?s not free and I only want to create an user account.
>I would like to use API of Windows. Is it possible?. Thanks
>
>
>"Eugene Mayevski" <mayevski@eldos.org> escribio en el mensaje
>news:3e9312bb@newsgroups.borland.com...
>> Fernando Alvarez wrote:
>> > Hi
>> >
>> > How I create an user account in Windows 2000/XP? And a group? I haven�t
>> > found any information. Thanks!!
>>
It is very easy for Windows Script:
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/ScriptCenter/user/ScrUG92.asp
The similar code for C++ Builder:
#include <objbase.h>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//The IBindCtx interface provides access to a bind context, which is an object
//that stores information about a particular moniker binding operation.
IBindCtx *pbindctx;
//The IMoniker interface is used for naming COM objects. An object that
//implements IMoniker is called a "moniker," which is a name that uniquely
//identifies a COM object.
IMoniker *pmoniker;
//Using later binding by moniker I will obtain pointer to dispatch interface
IDispatch *dispServ;
ULONG ul;
//Creates a bind context.
//A bind context is an object that stores information about a particular
//moniker-binding operation:
HRESULT hresult=::CreateBindCtx(0,&pbindctx);
if(hresult != S_OK)
{
ShowMessage("CreateBindCtx error");
pbindctx->Release();
Application->Terminate();
}
//Converts a string into a moniker that identifies the object named by the string.
//It's moniker for current computer: (//.)
hresult = ::MkParseDisplayName(pbindctx, L"WinNT://.,computer",&ul,&pmoniker);
if(hresult != S_OK)
{
ShowMessage("Sure, next time will be better.");
pbindctx->Release();
pmoniker->Release();
Application->Terminate();
}
//"Binds" the moniker; that is, returns a pointer to the object identified by the moniker.
//The binding process involves finding the object, getting it into the running
//state if it's not already, and acquiring an interface pointer to it.
//See carefully - I "get" Dispatch interface just for later binding
hresult=pmoniker->BindToObject(pbindctx,NULL,IID_IDispatch,(void**)&dispServ);
if(hresult != S_OK)
{
ShowMessage("They are still not here, bad day");
pbindctx->Release();
pmoniker->Release();
dispServ->Release();
Application->Terminate();
}
//Creating record for user ItsMe
Variant PCUser=((Variant)dispServ).Exec(Function("Create") << "user" << "ItsMe");
//setting password for user ItsMe
PCUser.Exec(Function("SetPassword") << "ABCd1924");
//Apply it:
PCUser.Exec(Function("SetInfo"));
}
It is create account for user ItsMe with password ABCd1924.
For further information see:
Microsoft Script Center:
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp
You can see also how to use monikers for WMI in C++
Builder in my samples:
Let us try WMI (samples)
http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=19443
Vladimir.
Re: User Accounts under Win2000
Author: Thorsten Meyer
Date: Fri, 02 May 2003 11:03
Date: Fri, 02 May 2003 11:03
127 lines
4795 bytes
4795 bytes
Hi,
thanks for the answer, but is there any Possibility to use the old API
function netuseradd() ?
Because I don't wanna change my old Code?!
regards for Answer
Thorsten Meyer
"Vladimir Afanasyev" <avv@systema.kiev.ua> schrieb im Newsbeitrag
news:3eaf75b0$1@newsgroups.borland.com...
>
> Hi Thorsten,
> It is my answer for similar question:Hi,
>
> "Fernando" <ferjat@terra.es> wrote:
> >Thank you, but SVC it?s not free and I only want to create an user
account.
> >I would like to use API of Windows. Is it possible?. Thanks
> >
> >
> >"Eugene Mayevski" <mayevski@eldos.org> escribio en el mensaje
> >news:3e9312bb@newsgroups.borland.com...
> >> Fernando Alvarez wrote:
> >> > Hi
> >> >
> >> > How I create an user account in Windows 2000/XP? And a group? I
haven�t
> >> > found any information. Thanks!!
> >>
>
> It is very easy for Windows Script:
>
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/ScriptCen
ter/user/ScrUG92.asp
>
> The similar code for C++ Builder:
>
>
> #include <objbase.h>
>
> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
> //The IBindCtx interface provides access to a bind context, which is an
object
> //that stores information about a particular moniker binding operation.
> IBindCtx *pbindctx;
>
> //The IMoniker interface is used for naming COM objects. An object that
> //implements IMoniker is called a "moniker," which is a name that uniquely
> //identifies a COM object.
> IMoniker *pmoniker;
>
> //Using later binding by moniker I will obtain pointer to dispatch
interface
> IDispatch *dispServ;
> ULONG ul;
>
> //Creates a bind context.
> //A bind context is an object that stores information about a particular
> //moniker-binding operation:
> HRESULT hresult=::CreateBindCtx(0,&pbindctx);
> if(hresult != S_OK)
> {
> ShowMessage("CreateBindCtx error");
> pbindctx->Release();
> Application->Terminate();
> }
>
> //Converts a string into a moniker that identifies the object named by the
string.
> //It's moniker for current computer: (//.)
> hresult = ::MkParseDisplayName(pbindctx,
L"WinNT://.,computer",&ul,&pmoniker);
> if(hresult != S_OK)
> {
> ShowMessage("Sure, next time will be better.");
> pbindctx->Release();
> pmoniker->Release();
> Application->Terminate();
> }
>
> //"Binds" the moniker; that is, returns a pointer to the object identified
by the moniker.
> //The binding process involves finding the object, getting it into the
running
> //state if it's not already, and acquiring an interface pointer to it.
> //See carefully - I "get" Dispatch interface just for later binding
>
hresult=pmoniker->BindToObject(pbindctx,NULL,IID_IDispatch,(void**)&dispServ
);
> if(hresult != S_OK)
> {
> ShowMessage("They are still not here, bad day");
> pbindctx->Release();
> pmoniker->Release();
> dispServ->Release();
> Application->Terminate();
> }
> //Creating record for user ItsMe
> Variant PCUser=((Variant)dispServ).Exec(Function("Create") << "user" <<
"ItsMe");
> //setting password for user ItsMe
> PCUser.Exec(Function("SetPassword") << "ABCd1924");
> //Apply it:
> PCUser.Exec(Function("SetInfo"));
> }
>
> It is create account for user ItsMe with password ABCd1924.
> For further information see:
> Microsoft Script Center:
>
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcen
ter/default.asp
>
> You can see also how to use monikers for WMI in C++
> Builder in my samples:
> Let us try WMI (samples)
> http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=19443
>
> Vladimir.
>
>
>
>
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads