Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

How do I read all user attributes without reading the user objects?

Last post 06-27-2008, 1:50 AM by joe. 3 replies.
Sort Posts: Previous Next
  •  06-25-2008, 5:21 PM 4045

    How do I read all user attributes without reading the user objects?

    I have a program that reads the first user in my query in order to obtain a list of user attributes, the problem with this is that the first user may not have all the attributes that other users have. For example the second user which I haven't read may have the manager attribute and the first user did not. How do I go about reading all the attributes that are available? I don't want to hard code them in as there may be a custom attribute added at some time that I'd then have to update the program to accomodate.

    Many thanks for the help.

    Dean
  •  06-25-2008, 8:10 PM 4046 in reply to 4045

    Re: How do I read all user attributes without reading the user objects?

    You typically read the schema for the object you want to discover.  You can do this with the System.DirectoryServices.ActiveDirectory namespace and the ActiveDirectorySchema class.  Alternatively, you can search yourself in the Config partition using normal searching techniques.  Finally, you can also inspect the 'allowedAttributes' for a given user and discover all the attributes on a given class.  I believe we have samples for all these techniques available in Chapter 7's code (free download).


    Ryan Dunn
    Extemporaneous Mumblings
    The .NET Developer's Guide to Directory Services Programming
  •  06-26-2008, 6:40 AM 4049 in reply to 4046

    Re: How do I read all user attributes without reading the user objects?

    Hi Ryan,

    Thanks for that, I have bought your book so I'll read up some more on reading the schema.

    Thanks

  •  06-27-2008, 1:50 AM 4056 in reply to 4049

    Re: How do I read all user attributes without reading the user objects?

    If you want to continue with the approach of getting the attribute list off of the first user, allowedAttributes is probably the way to go.  However, you may want to consider paring down the list to the stuff you really want.  For example, do you really need to read the security descriptor for every object?  Probably not unless it is needed.  Those are big, so you can waste some bandwidth and perf pulling them down for no reason.

    Overall, this isn't an easy problem to solve in general so the best thing to do will apply to the specifics of your situation.

View as RSS news feed in XML