Article View: borland.public.cppbuilder.nativeapi
Article #11100Re: Create Users on Win2K DC
From: K Y Iyer
Date: Fri, 27 Feb 2004 08:03
Date: Fri, 27 Feb 2004 08:03
102 lines
3692 bytes
3692 bytes
Hi
Here is the code - directly copied from MSDN. I am completely new to COM -
if this works, this will be the first app that I write using COM - so,
please, excuse stupid questions.
/***************************************************************/
#include "activeds.h"
void __fastcall TForm1::bNewClick(TObject *Sender)
{
HRESULT hr;
IADsContainer *pCont;
IDispatch *pDisp=NULL;
IADs *pUser;
// Initialize COM before calling any ADSI functions or interfaces.
CoInitialize(NULL);
hr = ADsGetObject(
L"LDAP://cn=users,dc=archana,dc=ndtv,dc=com",IID_IADsContainer, (void**)
&pCont );
if ( !SUCCEEDED(hr) )
{
return ;
}
//-----------------
// Create a user
//-----------------
/***************______THIS IS THE LINE THAT GENERATES *ALL* THE
ERRORS___________***********/
hr = pCont->Create(CComBSTR("user"), CComBSTR("jeffsmith"), &pDisp );
// Release the container object.
pCont->Release();
if ( !SUCCEEDED(hr) )
{
return ;
}
hr = pDisp->QueryInterface( IID_IADs, (void**) &pUser );
// Release the dispatch interface.
pDisp->Release();
if ( !SUCCEEDED(hr) )
{
return ;
}
// Commit the object data to the directory.
pUser->SetInfo();
// Release the object.
pUser->Release();
CoUninitialize();
}
/***************************************************************/
And here are the errors generated on the one line above - basically what do
I use in place of CComBSTR? That function seems to be the problem
/************________ERRORS__________*********************/
[C++ Error] browseEmployees.cpp(132): E2268 Call to undefined function
'CComBSTR'
[C++ Error] browseEmployees.cpp(132): E2034 Cannot convert 'int' to 'wchar_t
*'
[C++ Error] browseEmployees.cpp(132): E2342 Type mismatch in parameter
'ClassName' (wanted 'wchar_t *', got 'int')
[C++ Error] browseEmployees.cpp(132): E2034 Cannot convert 'int' to 'wchar_t
*'
[C++ Error] browseEmployees.cpp(132): E2342 Type mismatch in parameter
'RelativeName' (wanted 'wchar_t *', got 'int')
/***********************************************************/
Thanks very much
Iyer
"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> wrote in message
news:403ef128$1@newsgroups.borland.com...
>
> "K Y Iyer" <iyer@ndtv.com> wrote in message
> news:403ecddc@newsgroups.borland.com...
>
> > I want to create users/groups on our Win2K Domain using BCB
> > 6. I found documentation on MSDN on how to do this using VB.
> >
> > Can this be done with BCB6?
>
> Whatever VB uses should be usable in C++ as well. Please show the actual
> code.
>
>
> Gambit
>
>
Technical Details
Message-ID:
<403ef9d4@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<403ecddc@newsgroups.borland.com> <403ef128$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,92441ca3095726f0 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-27 00:09:46 PST From: "K Y Iyer" <iyer@ndtv.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <403ecddc@newsgroups.borland.com> <403ef128$1@newsgroups.borland.com> Subject: Re: Create Users on Win2K DC Date: Fri, 27 Feb 2004 13:33:58 +0530 Lines: 104 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: <403ef9d4@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1077869012 202.56.236.218 (27 Feb 2004 00:03:32 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail