Re: Authorization against AD using MC++

From: albier (
Date: 08/02/05

  • Next message: albier: "Re: Authorization against AD using MC++"
    Date: Tue, 2 Aug 2005 14:07:01 -0700

    Thanks for the pointers but I still don't know how to use the
    IEnumerable::GetEnumerator to be able to loop over the list of objects I
    have. I have tried the following code but got an error in for trying to
    type-cast groups.

    ArrayList* usersList = new ArrayList();
    System::Object* groups = de->Invoke("Groups", NULL);
    while (((IEnumerator*)groups)->MoveNext())
    DirectoryEntry* groupEntry = new

    It would be great if you can just show me how to use the
    IEnumerable::GetEnumerator in order to loop over the list of objects I have
    (groups*). Thanks again for your time,

    "Joe Kaplan (MVP - ADSI)" wrote:

    > You should probably just call the IEnumerable::GetEnumerator method and then
    > use its MoveNext and Current members to enumerate the group collection.
    > That is all foreach does under the hood.
    > Note that the actual approach you are using may not work for nested group
    > membership or the user's primary group. It is a better idea to do this kind
    > of authorization based on the user's logon token and the token_groups
    > structure inside of it.
    > Joe K.
    > "albier" <> wrote in message
    > >I wrote a code with C# to authorize users against AD. Here is the code:
    > >
    > > ArrayList usersList = new ArrayList();
    > > object groups = user.Invoke("Groups",null);
    > > foreach (object group in (IEnumerable)groups)
    > > {
    > > DirectoryEntry groupEntry = new DirectoryEntry(group);
    > > usersList.Add(groupEntry.Name);
    > > }
    > >
    > > This code is working perfectly. I'm having problems writing the same code
    > > using Managed C++. A similar code would be:
    > >
    > > ArrayList* usersList = new ArrayList();
    > > System::Object* groups = de->Invoke("Groups", NULL);
    > > while (groups != NULL)
    > > {
    > > DirectoryEntry* groupEntry = new DirectoryEntry(groups);
    > > usersList->Add(groupEntry->Name);
    > > groups++;
    > > }
    > >
    > > This code doesn't work since pointers in MC++ cannot be incremented and I
    > > cannot use them to refer to the variable they are pointing to. Since these
    > > pointers are __gc type (Garbage Collected), I cannot say *groups to refer
    > > to
    > > the value the pointer groups is pointing to. I also cannot say groups++ to
    > > increment the pointer so that groups would point to the next object in the
    > > list of objects. Please notice that the Invoke "Group" function would
    > > return
    > > a list of objects and I need to loop over this list. Do you have a
    > > solution
    > > for this problem? Do you have any other idea of how to implement the C#
    > > code
    > > above?
    > > Thanks for your help,
    > > Albier Michaiel
    > >
    > >

  • Next message: albier: "Re: Authorization against AD using MC++"

    Relevant Pages

    • Re: loop performance question
      ... | such that every possible pair in the array is tested. ... | whenever I access any data in the second loop. ... The pointers to separately allocated objects break the ... Then comes the question of how to avoid cache misses when accessing obj2. ...
    • Re: Problems with a secondary message pump
      ... it says that the dwWakeMask is 'the input types for ... array that I don't want to stop the loop on. ... was just a guess that OnIdle is freeing them, ... getting pointers to the wizard's system menu and Cancel button and storing ...
    • Re: newbie question
      ... The second assigns a pointer to an array 1000 of char to an int pointer. ... What you pass are the file pointers, ... > second file is identical to the first. ... Look at your while loop. ...
    • Re: GC.Collect
      ... Thanks for the suggestions / pointers, they will definitely help me in making a wise decision. ... No major allocations are done in that loop, essntially not a very heavy work per iteration. ... Well for each 65'000 of those objects the gen0 in .NET 1.1 will get full, the GC kicks in and move most of them to gen1. ...
    • Re: cannot understand strrev implementation
      ... This loop finds the last character in the string. ... 'string' pointers, and then moves them towards each other, stopping when ... Ask your assistant to swap the cards that you are pointing to. ...