๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11104

Re: Create Users on Win2K DC

#11104
From: K Y Iyer
Date: Fri, 27 Feb 2004 08:57
123 lines
4776 bytes
Vladimir

What about the sample code from MSDN that I posted earlier?  What is the
difference between your sample and MSDN?

Thanks very much

Best wishes

Iyer
"Vladimir Afanasyev" <avv@systema.kiev.ua> wrote in message
news:403efb7a$1@newsgroups.borland.com...
>
> Hi Iyer,
> It is my old message in this group that explain how to do it.
>
> The follow code works for BCB5 but BCB6 has some incompatibility
> with BCB5. To make it work for BCB6 open menu Project->Options then
> page Advanced Compiler and set Register variable in None.
>
> Vladimir.
>
>
> >"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
>
>
Technical Details
Message-ID: <403f064d@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-05!sn-xit-09!supernews.com!newsread.com!newsstand.newsread.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <403ecddc@newsgroups.borland.com> <403efb7a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10cc67,92441ca3095726f0
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-27 01:09:43 PST
From: "K Y Iyer" <iyer@ndtv.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References:  <403ecddc@newsgroups.borland.com> <403efb7a$1@newsgroups.borland.com>
Subject: Re: Create Users on Win2K DC
Date: Fri, 27 Feb 2004 14:27:11 +0530
Lines: 125
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 202.56.236.218
Message-ID: <403f064d@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1077872205 202.56.236.218 (27 Feb 2004 00:56:45 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-05!sn-xit-09!supernews.com!newsread.com!newsstand.newsread.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail