Recipe 6.30 Viewing a User's Managed Objects
You want to view the objects owned by a user.
184.108.40.206 Using a graphical user interface
220.127.116.11 Using a command-line interface
> enumprop /ATTR:managedObjects "LDAP://<UserDN>"
18.104.22.168 Using VBScript
' This code displays the managed objects for a user ' ------ SCRIPT CONFIGURATION ------ strUserDN = "<UserDN>" ' e.g. cn=jsmith,cn=Users,dc=rallencorp,dc=com ' ------ END CONFIGURATION --------- on error resume next set objUser = GetObject("LDAP://" & strUserDN) Wscript.Echo objUser.Get("cn") & "'s Managed Objects:" colObjects = objUser.GetEx("managedObjects") if Err.Number = -2147463155 then Wscript.Echo " none" else for each strObjectDN in colObjects Wscript.Echo " " & strObjectDN next end if
The managedObjects attribute is linked to the managedBy attribute that can be set on certain objects in Active Directory like computers and groups. Setting the managedBy attribute provides a quick and dirty way to define who owns an object. If you do use it, you can use the managedObjects attribute on user objects to get the list of objects the user has been configured in the managedBy attribute for.