本文整理汇总了C++中IADs::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ IADs::Get方法的具体用法?C++ IADs::Get怎么用?C++ IADs::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IADs
的用法示例。
在下文中一共展示了IADs::Get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyCom_BuildPyException
// @pymethod object|PyIADs|Get|Description of Get.
// @rdesc The result is a Python object converted from a COM variant. It
// may be an array, or any types supported by COM variant.
PyObject *PyIADs::Get(PyObject *self, PyObject *args)
{
IADs *pIAD = GetI(self);
if ( pIAD == NULL )
return NULL;
VARIANT val;
VariantInit(&val);
// @pyparm <o PyUnicode>|prop||The name of the property to fetch
PyObject *obbstrName;
BSTR bstrName;
if ( !PyArg_ParseTuple(args, "O:Get", &obbstrName) )
return NULL;
BOOL bPythonIsHappy = TRUE;
if (bPythonIsHappy && !PyWinObject_AsBstr(obbstrName, &bstrName)) bPythonIsHappy = FALSE;
if (!bPythonIsHappy) return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIAD->Get( bstrName, &val );
SysFreeString(bstrName);
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pIAD, IID_IADs );
PyObject *ret = PyCom_PyObjectFromVariant(&val);
{
PY_INTERFACE_PRECALL;
VariantClear(&val);
PY_INTERFACE_POSTCALL;
}
return ret;
}
示例2: main
int main(int argc, char* argv[])
{
wprintf(L"This program checks whether the current domain is in mixed or native mode.\n");
//Intialize COM
CoInitialize(NULL);
HRESULT hr = S_OK;
//Get rootDSE and the domain container's DN.
IADs *pObject = NULL;
VARIANT var;
BOOL bIsMixed;
LPOLESTR szPath = new OLECHAR[MAX_PATH];
if ( !szPath )
{
wprintf(L"Alloc Failed");
return FALSE;
}
hr = ADsOpenObject(L"LDAP://rootDSE",
NULL,
NULL,
ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
IID_IADs,
(void**)&pObject);
if (FAILED(hr))
{
wprintf(L"Not Found. Could not bind to the domain.\n");
if (pObject)
pObject->Release();
delete [] szPath;
CoUninitialize();
return TRUE;
}
hr = pObject->Get(L"defaultNamingContext",&var);
if (SUCCEEDED(hr))
{
wcscpy_s(szPath,MAX_PATH,L"LDAP://"); //For NT 4.0 and Win 9.x, you must add the server name, e.g LDAP://myServer
int len = wcslen(szPath);
int dnLen = wcslen( var.bstrVal);
if ( MAX_PATH <= len + dnLen ) // make sure we have enough buffer
{
wprintf(L"The buffer is too small for the DN\n");
pObject->Release();
VariantClear(&var);
delete [] szPath;
CoUninitialize();
return FALSE;
}
wcscat_s(szPath,MAX_PATH,var.bstrVal);
VariantClear(&var);
if (pObject)
{
pObject->Release();
pObject = NULL;
}
//Bind to the root of the current domain.
hr = ADsOpenObject(szPath,
NULL,
NULL,
ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
IID_IADs,
(void**)&pObject);
if (SUCCEEDED(hr))
{
hr = GetDomainMode(pObject, &bIsMixed);
if (SUCCEEDED(hr))
{
hr = pObject->Get(L"name",&var);
if (bIsMixed)
wprintf(L"Current domain %s is in mixed mode\n", var.bstrVal);
else
wprintf(L"Current domain %s is in native mode\n", var.bstrVal);
}
else
wprintf(L"GetDomainMode failed with hr: %x",hr);
}
else
wprintf(L"Bind to domain failed with hr: %x",hr);
}
VariantClear(&var);
if (pObject)
pObject->Release();
delete [] szPath;
CoUninitialize();
return TRUE;
}
示例3: wmain
//.........这里部分代码省略.........
wprintf(L"\nFinding %sSchema objects based on query: %s...\n\n",szType, pszBuffer);
HRESULT hr = S_OK;
//Get rootDSE and the domain container's DN.
IADs *pObject = NULL;
IDirectorySearch *pSchemaNC = NULL;
const unsigned int pathLen = MAX_PATH;
LPOLESTR szPath = new OLECHAR[pathLen];
if ( !szPath )
{
wprintf(L"Alloc Failed ");
delete [] pszBuffer;
return;
}
//Intialize COM
CoInitialize(NULL);
VARIANT var;
hr = ADsOpenObject(L"LDAP://rootDSE",
NULL,
NULL,
ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
IID_IADs,
(void**)&pObject);
if (FAILED(hr))
{
wprintf(L"Could not execute query. Could not bind to LDAP://rootDSE.\n");
if (pObject)
pObject->Release();
delete [] pszBuffer;
delete [] szPath;
CoUninitialize();
return;
}
if (SUCCEEDED(hr))
{
hr = pObject->Get(L"schemaNamingContext",&var);
if (SUCCEEDED(hr))
{
wcscpy_s(szPath,pathLen,L"LDAP://");
if ( IS_BUFFER_ENOUGH(MAX_PATH,szPath, var.bstrVal, SysStringLen(var.bstrVal)) > 0 )
{
wcscat_s(szPath,pathLen,var.bstrVal);
}
else
{
wprintf(L"The Schema's DN is too large");
pObject->Release();
delete [] pszBuffer;
delete [] szPath;
CoUninitialize();
return;
}
hr = ADsOpenObject(szPath,
NULL,
NULL,
ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
IID_IDirectorySearch,
(void**)&pSchemaNC);
if (SUCCEEDED(hr))
{
hr = FindAttributesOrClasses(pSchemaNC, //IDirectorySearch pointer to schema naming context.
pszBuffer,
NULL,
bIsAttributeQuery,
bReturnVerbose
);
if (SUCCEEDED(hr))
{
if (S_FALSE==hr)
wprintf(L"No %sSchema object could be found based on the query: %s\n",szType,pszBuffer);
}
else if (0x8007203e==hr)
wprintf(L"Could not execute query. An invalid filter was specified.\n");
else
wprintf(L"Query failed to run. HRESULT: %x\n",hr);
}
else
{
wprintf(L"Could not execute query. Could not bind to the schema container.\n");
}
if (pSchemaNC)
pSchemaNC->Release();
}
VariantClear(&var);
}
if (pObject)
pObject->Release();
delete [] pszBuffer;
delete [] szPath;
// Uninitialize COM
CoUninitialize();
return;
}
示例4: CUGP
LDAPAUTH_API
BOOL CUGP(char * userin,char *password,char *machine, char * groupin,int locdom)
{
OSVERSIONINFO ovi = { sizeof ovi };
GetVersionEx( &ovi );
if (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT &&
ovi.dwMajorVersion >= 5 )
{
//Handle the command line arguments.
LPOLESTR pszBuffer = new OLECHAR[MAX_PATH*2];
LPOLESTR pszBuffer2 = new OLECHAR[MAX_PATH*2];
LPOLESTR pszBuffer3 = new OLECHAR[MAX_PATH*2];
LPOLESTR pszBuffer4 = new OLECHAR[MAX_PATH*2];
mbstowcs( (wchar_t *) pszBuffer, userin, MAX_PATH );
mbstowcs( (wchar_t *) pszBuffer2, password, MAX_PATH );
mbstowcs( (wchar_t *) pszBuffer3, machine, MAX_PATH );
mbstowcs( (wchar_t *) pszBuffer4, groupin, MAX_PATH );
HRESULT hr = S_OK;
//Get rootDSE and the domain container's DN.
IADs *pObject = NULL;
IADs *pObjectUser = NULL;
IADs *pObjectGroup = NULL;
IDirectorySearch *pDS = NULL;
LPOLESTR szPath = new OLECHAR[MAX_PATH];
LPOLESTR myPath = new OLECHAR[MAX_PATH];
VARIANT var;
wcscpy(szPath,L"LDAP://");
wcscat(szPath,L"rootDSE");
wprintf(szPath);
wprintf(L"\n");
hr = ADsOpenObject(szPath,
pszBuffer,
pszBuffer2,
ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
IID_IADs,
(void**)&pObject);
if (FAILED(hr))
{
wprintf(L"Bind to domain failed %i\n",hr);
if (pObject) pObject->Release();
delete [] pszBuffer;
delete [] pszBuffer2;
delete [] pszBuffer3;
delete [] pszBuffer4;
delete [] szPath;
delete [] myPath;
return false;
}
hr = pObject->Get(L"defaultNamingContext",&var);
if (SUCCEEDED(hr))
{
wcscpy(szPath,L"LDAP://");
wcscat(szPath,var.bstrVal);
VariantClear(&var);
if (pObject)
{
pObject->Release();
pObject = NULL;
}
wprintf( szPath);
wprintf(L"\n");
//Bind to the root of the current domain.
hr = ADsOpenObject(szPath,pszBuffer,pszBuffer2,
ADS_SECURE_AUTHENTICATION,IID_IDirectorySearch,(void**)&pDS);
if (SUCCEEDED(hr))
{
if (SUCCEEDED(hr))
{
hr = FindUserByName(pDS, pszBuffer, &pObjectUser);
if (FAILED(hr))
{
wprintf(L"User not found %i\n",hr);
delete [] pszBuffer;
delete [] pszBuffer2;
delete [] pszBuffer3;
delete [] szPath;
delete [] myPath;
if (pDS) pDS->Release();
if (pObjectUser) pObjectUser->Release();
return false;
}
if (pObjectUser) pObjectUser->Release();
///////////////////// VNCACCESS
hr = FindGroup(pDS, pszBuffer, &pObjectGroup,pszBuffer4);
if (pObjectGroup)
{
pObjectGroup->Release();
pObjectGroup = NULL;
}
if (FAILED(hr)) wprintf(L"group not found\n");
if (SUCCEEDED(hr))
{
wprintf(L"Group found OK\n");
IADsGroup * pIADsG;
hr = ADsOpenObject( gbsGroup,pszBuffer, pszBuffer2,
ADS_SECURE_AUTHENTICATION,IID_IADsGroup, (void**) &pIADsG);
//.........这里部分代码省略.........
示例5: GetDeletedObjectsContainer
//----------------------------------------------------------------------------
//
// GetDeletedObjectsContainer()
//
// Binds to the Deleted Object container.
//
//----------------------------------------------------------------------------
HRESULT GetDeletedObjectsContainer(IADsContainer **ppContainer)
{
if(NULL == ppContainer)
{
return E_INVALIDARG;
}
HRESULT hr;
IADs *pRoot;
*ppContainer = NULL;
// Bind to the rootDSE object.
hr = ADsOpenObject(L"LDAP://rootDSE",
NULL,
NULL,
ADS_SECURE_AUTHENTICATION,
IID_IADs,
(LPVOID*)&pRoot);
if(SUCCEEDED(hr))
{
VARIANT var;
VariantInit(&var);
// Get the current domain DN.
hr = pRoot->Get(L"defaultNamingContext", &var);
if(SUCCEEDED(hr))
{
// Build the binding string.
LPWSTR pwszFormat = L"LDAP://<WKGUID=%s,%s>";
LPWSTR pwszPath;
pwszPath = new WCHAR[wcslen(pwszFormat) + wcslen(GUID_DELETED_OBJECTS_CONTAINER_W) + wcslen(var.bstrVal)];
if(NULL != pwszPath)
{
swprintf(pwszPath, pwszFormat, GUID_DELETED_OBJECTS_CONTAINER_W, var.bstrVal);
// Bind to the object.
hr = ADsOpenObject(pwszPath,
NULL,
NULL,
ADS_FAST_BIND | ADS_SECURE_AUTHENTICATION,
IID_IADsContainer,
(LPVOID*)ppContainer);
delete pwszPath;
}
else
{
hr = E_OUTOFMEMORY;
}
VariantClear(&var);
}
pRoot->Release();
}
return hr;
}
示例6: wmain
void wmain( int argc, wchar_t *argv[ ])
{
//Handle the command line arguments.
LPOLESTR pszBuffer = NULL;
pszBuffer = new OLECHAR[MAX_PATH*2];
if(pszBuffer == NULL)
goto ret;
if (argv[1] == NULL)
{
wprintf(L"This program finds a user in the current Window 2000 domain\n");
wprintf(L"and displays its objectSid property in string form.\n");
wprintf(L"This program demonstrates reading a property of type octet string.\n\n");
wprintf(L"Enter Common Name of the user to find:");
if ( !_getws_s(pszBuffer, MAX_PATH*2))
{
delete [] pszBuffer;
wprintf(L"String exceeded buffer size.\n\n");
return;
}
}
else
if ( !wcscpy_s(pszBuffer, MAX_PATH*2, argv[1]))
{
delete [] pszBuffer;
wprintf(L"String exceeded buffer size.\n\n");
return;
}
//if empty string, exit.
if (0==wcscmp(L"", pszBuffer))
goto ret;
wprintf(L"\nFinding user: %s...\n",pszBuffer);
//Intialize COM
CoInitialize(NULL);
HRESULT hr = S_OK;
//Get rootDSE and the domain container's DN.
IADs *pObject = NULL;
IDirectorySearch *pDS = NULL;
LPOLESTR szPath = NULL;
szPath = new OLECHAR[MAX_PATH];
if(szPath == NULL)
goto ret;
VARIANT var;
hr = ADsOpenObject(L"LDAP://rootDSE",
NULL,
NULL,
ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
IID_IADs,
(void**)&pObject);
if (FAILED(hr))
{
wprintf(L"Not Found. Could not bind to the domain.\n");
if (pObject)
pObject->Release();
goto ret;
}
VariantInit(&var);
hr = pObject->Get(L"defaultNamingContext",&var);
if (SUCCEEDED(hr))
{
wcscpy_s(szPath,MAX_PATH,L"LDAP://");
wcscat_s(szPath,MAX_PATH,var.bstrVal);
VariantClear(&var);
if (pObject)
{
pObject->Release();
pObject = NULL;
}
//Bind to the root of the current domain.
hr = ADsOpenObject(szPath,
NULL,
NULL,
ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
IID_IDirectorySearch,
(void**)&pDS);
if (SUCCEEDED(hr))
{
hr = FindUserByName(pDS, //Container to search
pszBuffer, //Name of user to find.
&pObject); //Return a pointer to the user
if (SUCCEEDED(hr))
{
//Get the objectSid property
hr = pObject->Get(L"objectSid", &var);
if (SUCCEEDED(hr))
{
LPBYTE pByte = NULL;
wprintf (L"----------------------------------------------\n");
wprintf (L"----------Call GetLPBYTEtoOctetString---------\n");
wprintf (L"----------------------------------------------\n");
hr = GetLPBYTEtoOctetString(&var, //IN. Pointer to variant containing the octetstring.
&pByte //OUT. Return LPBYTE to the data represented in octetstring.
);
PSID pObjectSID = (PSID)pByte;
//.........这里部分代码省略.........
示例7: wmain
void wmain( int argc, wchar_t *argv[])
{
//Handle the command line arguments.
int maxAlloc = MAX_PATH*2;
LPOLESTR pszBuffer = new OLECHAR[maxAlloc];
wcscpy_s(pszBuffer, maxAlloc, L"");
BOOL bReturnVerbose = FALSE;
for (int i = 1;i<argc;i++)
{
if (_wcsicmp(argv[i],L"/V") == 0)
{
bReturnVerbose = TRUE;
}
else if ((_wcsicmp(argv[i],L"/?") == 0)||
(_wcsicmp(argv[i],L"-?") == 0))
{
wprintf(L"This program queries for users in the current user's domain.\n");
wprintf(L"Syntax: queryusers [/V][querystring]\n");
wprintf(L"where /V specifies that all properties for the found users should be returned.\n");
wprintf(L" querystring is the query criteria in ldap query format.\n");
wprintf(L"Defaults: If no /V is specified, the query returns only the RDN and DN of the items found.\n");
wprintf(L" If no querystring is specified, the query returns all users.\n");
wprintf(L"Example: queryusers (sn=Smith)\n");
wprintf(L"Returns all users with surname Smith.\n");
return;
}
else
{
if ( IS_BUFFER_ENOUGH(maxAlloc, pszBuffer, argv[i]) > 0 )
{
wcscpy_s(pszBuffer,maxAlloc,argv[i]);
}
else
{
wprintf(L"Buffer is too small for the argument");
delete [] pszBuffer;
return;
}
}
}
if (_wcsicmp(pszBuffer,L"") == 0)
wprintf(L"\nFinding all user objects...\n\n");
else
wprintf(L"\nFinding user objects based on query: %s...\n\n", pszBuffer);
//Initialize COM
CoInitialize(NULL);
HRESULT hr = S_OK;
//Get rootDSE and the current user's domain container DN.
IADs *pObject = NULL;
IDirectorySearch *pContainerToSearch = NULL;
LPOLESTR szPath = new OLECHAR[MAX_PATH];
VARIANT var;
hr = ADsOpenObject(L"LDAP://rootDSE",
NULL,
NULL,
ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
IID_IADs,
(void**)&pObject);
if (FAILED(hr))
{
wprintf(L"Could not execute query. Could not bind to LDAP://rootDSE.\n");
if (pObject)
pObject->Release();
delete [] pszBuffer;
delete [] szPath;
CoUninitialize();
return;
}
if (SUCCEEDED(hr))
{
hr = pObject->Get(L"defaultNamingContext",&var);
if (SUCCEEDED(hr))
{
//Build path to the domain container.
wcscpy_s(szPath,MAX_PATH,L"LDAP://");
if ( IS_BUFFER_ENOUGH(MAX_PATH, szPath, var.bstrVal) > 0 )
{
wcscat_s(szPath,MAX_PATH,var.bstrVal);
}
else
{
wprintf(L"Buffer is too small for the domain DN");
delete [] pszBuffer;
delete [] szPath;
CoUninitialize();
return;
}
hr = ADsOpenObject(szPath,
NULL,
NULL,
ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
IID_IDirectorySearch,
(void**)&pContainerToSearch);
if (SUCCEEDED(hr))
//.........这里部分代码省略.........
示例8: CUGP
LDAPAUTHNT4_API
BOOL CUGP(char * userin,char *password,char *machine,char *groupin,int locdom)
{
{
//Handle the command line arguments.
LPOLESTR pszBuffer = new OLECHAR[MAX_PATH*2];
LPOLESTR pszBuffer2 = new OLECHAR[MAX_PATH*2];
LPOLESTR pszBuffer3 = new OLECHAR[MAX_PATH*2];
LPOLESTR pszBuffer4 = new OLECHAR[MAX_PATH*2];
mbstowcs( (wchar_t *) pszBuffer, userin, MAX_PATH );
mbstowcs( (wchar_t *) pszBuffer2, password, MAX_PATH );
mbstowcs( (wchar_t *) pszBuffer3, machine, MAX_PATH );
mbstowcs( (wchar_t *) pszBuffer4, groupin, MAX_PATH );
HRESULT hr = S_OK;
//Get rootDSE and the domain container's DN.
IADs *pObject = NULL;
IADs *pObjectUser = NULL;
IADs *pObjectGroup = NULL;
IDirectorySearch *pDS = NULL;
LPOLESTR szPath = new OLECHAR[MAX_PATH];
LPOLESTR myPath = new OLECHAR[MAX_PATH];
VARIANT var;
////////////FIND SERVER NEEDED FOR NT4
DWORD dwRet;
PDOMAIN_CONTROLLER_INFO pdci;
dwRet = DsGetDcName(NULL, NULL, NULL, NULL , DS_PDC_REQUIRED, &pdci);
if (ERROR_SUCCESS!=dwRet)
{
wprintf(L"PDC not found try a rediscover \n");
dwRet = DsGetDcName(NULL, NULL, NULL, NULL , DS_DIRECTORY_SERVICE_REQUIRED|DS_FORCE_REDISCOVERY, &pdci);
if (ERROR_SUCCESS!=dwRet)
{
wprintf(L"PDC not found \n");
delete [] pszBuffer;
delete [] pszBuffer2;
delete [] pszBuffer3;
delete [] pszBuffer4;
delete [] szPath;
delete [] myPath;
return false;
}
}
//////////////////////////////////////////
wcscpy(szPath,L"LDAP://");
wcscat(szPath,pdci->DomainControllerName+2);
wcscat(szPath,L"/rootDSE");
wprintf(szPath);
wprintf(L"\n");
hr = ADsOpenObject(szPath,
pszBuffer,
pszBuffer2,
ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
IID_IADs,
(void**)&pObject);
if (FAILED(hr))
{
bool result=false;
delete [] pszBuffer;
delete [] pszBuffer2;
delete [] pszBuffer3;
delete [] pszBuffer4;
delete [] szPath;
delete [] myPath;
return result;
}
hr = pObject->Get(L"defaultNamingContext",&var);
if (SUCCEEDED(hr))
{
wcscpy(szPath,L"LDAP://");
wcscat(szPath,pdci->DomainControllerName+2);
wcscat(szPath,L"/");
wcscat(szPath,var.bstrVal);
VariantClear(&var);
if (pObject)
{
pObject->Release();
pObject = NULL;
}
wprintf( szPath);
wprintf(L"\n");
//Bind to the root of the current domain.
hr = ADsOpenObject(szPath,pszBuffer,pszBuffer2,
ADS_SECURE_AUTHENTICATION,IID_IDirectorySearch,(void**)&pDS);
if (SUCCEEDED(hr))
{
if (SUCCEEDED(hr))
{
hr = FindUserByName(pDS, pszBuffer, &pObjectUser );
if (FAILED(hr))
{
delete [] pszBuffer;
delete [] pszBuffer2;
delete [] pszBuffer3;
delete [] pszBuffer4;
delete [] szPath;
delete [] myPath;
if (pDS) pDS->Release();
//.........这里部分代码省略.........