Click here to Skip to main content
14,486,466 members
   

C#

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder12-Jul-09 22:36
cofounderChris Maunder12-Jul-09 22:36 
PinnedHow to get an answer to your question Pin
Chris Maunder10-Nov-05 16:31
cofounderChris Maunder10-Nov-05 16:31 
QuestionOverloaded Methods with Generics Pin
#realJSOP5hrs 10mins ago
mva#realJSOP5hrs 10mins ago 
AnswerRe: Overloaded Methods with Generics Pin
OriginalGriff4hrs 28mins ago
mveOriginalGriff4hrs 28mins ago 
GeneralRe: Overloaded Methods with Generics Pin
#realJSOP4hrs 12mins ago
mva#realJSOP4hrs 12mins ago 
GeneralRe: Overloaded Methods with Generics Pin
OriginalGriff2hrs 34mins ago
mveOriginalGriff2hrs 34mins ago 
QuestionWpf Excel Pin
RajaMohammed.A26-Mar-20 3:55
MemberRajaMohammed.A26-Mar-20 3:55 
AnswerRe: Wpf Excel Pin
Richard MacCutchan26-Mar-20 4:12
mveRichard MacCutchan26-Mar-20 4:12 
QuestionC# Oracle SYSDBA connection string not able to working on windows 10? Pin
barathsamkumar25-Mar-20 4:39
Memberbarathsamkumar25-Mar-20 4:39 
AnswerRe: C# Oracle SYSDBA connection string not able to working on windows 10? Pin
OriginalGriff25-Mar-20 5:13
mveOriginalGriff25-Mar-20 5:13 
AnswerRe: C# Oracle SYSDBA connection string not able to working on windows 10? Pin
ZurdoDev25-Mar-20 10:07
mveZurdoDev25-Mar-20 10:07 
QuestionUser List Pin
Richard Andrew x6423-Mar-20 10:40
professionalRichard Andrew x6423-Mar-20 10:40 
AnswerRe: User List Pin
Luc Pattyn23-Mar-20 16:25
sitebuilderLuc Pattyn23-Mar-20 16:25 
GeneralRe: User List Pin
Richard Andrew x6424-Mar-20 2:06
professionalRichard Andrew x6424-Mar-20 2:06 
GeneralRe: User List Pin
Dave Kreskowiak25-Mar-20 4:13
mveDave Kreskowiak25-Mar-20 4:13 
AnswerRe: User List Pin
Randor 25-Mar-20 5:11
professional Randor 25-Mar-20 5:11 
GeneralRe: User List Pin
Richard Andrew x6425-Mar-20 5:33
professionalRichard Andrew x6425-Mar-20 5:33 
GeneralRe: User List Pin
Randor 25-Mar-20 6:10
professional Randor 25-Mar-20 6:10 
GeneralRe: User List Pin
Richard Andrew x6425-Mar-20 6:22
professionalRichard Andrew x6425-Mar-20 6:22 
GeneralRe: User List Pin
Randor 25-Mar-20 8:38
professional Randor 25-Mar-20 8:38 
GeneralRe: User List Pin
Richard Andrew x6425-Mar-20 8:57
professionalRichard Andrew x6425-Mar-20 8:57 
GeneralRe: User List Pin
Randor 25-Mar-20 9:18
professional Randor 25-Mar-20 9:18 
AnswerRe: User List Pin
Randor 25-Mar-20 13:27
professional Randor 25-Mar-20 13:27 
Hmmmm,

You haven't answered yet and since I am under forced quarantine/lockdown orders I threw this together for you. You will have to figure out how to translate it to C#

I apologize in advance for the nested IF statements. It's a code sample and I don't really feel like taking the time to make it look pretty.

// For Richard Andrew x64
//

#pragma comment(lib, "adsiid.lib")
#pragma comment(lib, "Activeds.lib")

#include <iostream>
#include <windows.h>
#include <atlbase.h>
#include <activeds.h>
#include <iads.h>
#include <adshlp.h>
#include <strsafe.h>

INT main()
{
    IADsClass* pClass = NULL;
    IADs* pADs;
    BSTR bstrSchema;
    VARIANT var;
    IEnumVARIANT* pEnumerator = NULL;
    IADsContainer* pContainer = NULL;
    ULONG count;
    IADs* pChild = NULL;
    WCHAR ad_path[MAX_PATH] = { 0 };
    WCHAR computer_name[MAX_COMPUTERNAME_LENGTH] = { 0 };

    count = MAX_COMPUTERNAME_LENGTH;
    GetComputerName(computer_name, &count);
    
    count = MAX_PATH;
    if (SUCCEEDED(CoInitialize(NULL)))
    {
        if (SUCCEEDED(StringCchPrintfW(ad_path, count, L"WinNT://%s,computer", computer_name)))
        {
            if (SUCCEEDED(ADsGetObject(ad_path, IID_IADsContainer, (void**)&pContainer)))
            {
                if (SUCCEEDED(ADsBuildEnumerator(pContainer, &pEnumerator)))
                {
                    VariantInit(&var);
                    while (SUCCEEDED(ADsEnumerateNext(pEnumerator, 1, &var, &count)) && count == 1)
                    {
                        if (SUCCEEDED(V_DISPATCH(&var)->QueryInterface(IID_IADs, (void**)&pChild)))
                        {
                            BSTR bstrClass;
                            pChild->get_Class(&bstrClass);

                            if (CComBSTR(bstrClass) == CComBSTR(L"User"))
                            {
                                IADsUser* user = nullptr;
                                if (SUCCEEDED(pChild->QueryInterface(&user)))
                                {
                                    VARIANT_BOOL is_disabled;
                                    user->get_AccountDisabled(&is_disabled);
                                    if (VARIANT_FALSE == is_disabled)
                                    {
                                        BSTR bstrName;
                                        pChild->get_Name(&bstrName);
                                        std::wcout << bstrName << std::endl;
                                        SysFreeString(bstrName);
                                        pChild->Release();
                                    }
                                }
                            }
                            pChild->Release();
                        }
                        VariantClear(&var);
                    }
                    ADsFreeEnumerator(pEnumerator);
                }
                pContainer->Release();
            }
        }
    }

    CoUninitialize();
    return 0;
}


Best Wishes,
-David Delaune
GeneralRe: User List Pin
Richard Andrew x6425-Mar-20 13:36
professionalRichard Andrew x6425-Mar-20 13:36 
GeneralRe: User List Pin
Richard Andrew x6427-Mar-20 14:37
professionalRichard Andrew x6427-Mar-20 14:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.