Platform SDK: Active Directory, ADSI, and Directory Services |
The following code fragment changes the scope of a group:
WCHAR pwszLDAPPath[MAX_PATH*2]; HRESULT hr; IADsGroup * pGroup = NULL; // Initialize COM CoInitialize(0); // Bind to the container passed hr = ADsGetObject( pwszLDAPPath, IID_IADsGroup,(void **)&pGroup); if (SUCCEEDED(hr)) { VARIANT vValue; BSTR bsValue = SysAllocString(L"groupType"); VariantInit(&vValue); // Set a new GroupType Value vValue.vt = VT_I4; vValue.lVal = ADS_GROUP_TYPE_GLOBAL_GROUP ; hr = pGroup->Put(bsValue,vValue); hr = pGroup->SetInfo(); pGroup->Release(); pGroup= NULL; } CoUninitialize();
The following code fragment changes the scope of a group:
Dim x as IADs Set x = GetObject("LDAP://CN=mygroup,OU=myou,DC=Microsoft,DC=com") x.Put "groupType", ADS_GROUP_TYPE_UNIVERSAL_GROUP|ADS_GROUP_TYPE_SECURITY_ENABLED