locked
User Attributes through DirectoryServices ??? RRS feed

  • Question

  • User496185299 posted
    Where oh where are the user properties being hidden?  Using the following code I can only get 29 basic properties.  I do not see the attibributes such as, address, telephone number, profile path, etc.  Can anyone assist?

         private void adObjectProperties(DirectoryEntry selectedNode)
            {
                PropertyCollection coll = selectedNode.Properties;
                foreach (string name in coll.PropertyNames)
                {
                    ListViewItem item = detailsListView.Items.Add(name.ToString());
                    item.SubItems.Add(coll[name].Value.ToString());
                }

    Here is the list of properties I get with this code.  What am I doing wrong?

    accountExpires
    badPasswordTime
    badPwdCount
    cn
    codePage
    countryCode
    displayName
    distinguishedName
    givenName
    instanceType
    lastLogoff
    lastLogon
    logonCount
    name
    nTSecurityDescriptor
    objectCategory
    objectClass
    objectGUID
    objectSid
    primaryGroupID
    pwdLastSet
    sAMAccountName
    sAMAccountType
    userAccountControl
    userPrincipalName
    uSNChanged
    uSNCreated
    whenChanged
    whenCreated

    Thanks in advance.

    hagan3

    Wednesday, March 1, 2006 9:33 AM

All replies

  • User1354132231 posted
    Welcome to the forums.  These attributes are the a.) non-constructed, b.)populated, and c.) the ones you have permission to view.

    If you want to know what is possible, you need to either check the schema documentation, inspect the allowedChildAttributes attribute (constructed attribute, so not shown above), or programmatically inspect the schema.  Incidentally, that is exactly what the 'allowedChildAttributes' attribute is doing.

    Here is an example of how to programmatically inspect that schema.  It is even easier in 2.0 with .ActiveDirectoryNamespace.

    http://dunnry.com/blog/WhatAttributesAreAvailableOnMyActiveDirectoryObject.aspx
    Wednesday, March 1, 2006 1:46 PM
  • User496185299 posted

    Huge Thank You!  I see now that when I populate an attribute with a value that the attribute name is provided in the PropertyCollection.  Seems like this code would provide all property names whether they were valued or not.  Unique, but works for me.

    Where is the definitive guide to coding DirectoryServices.  I see there is one on the way in May or so (Congrats! - Will be picking it up as soon as it hits the shelf.), but are there sources?

    Great forum!

    hagan3

    Wednesday, March 1, 2006 3:04 PM