Recipe 5.29. Retrieving Properties on User AccountsProblemYou need to retrieve a list of properties on user accounts. SolutionUsing a graphical user interface
Using a command-line interfaceRun the following command: > ldifde -f c:\outfile.ldf -r "(&(objectClass=User)(objectCategory=Person))" -d "cn=<Username>,cn=users, <ForestRootDN>" This will create an LDIF-format file called outfile.ldf, which you can view with your favorite text editor. Using VBScript' This code dumps most of the properties on the selected user object. 'To output to a text file, run 'cscript filename.vbs >outfile.txt' ' ------ SCRIPT CONFIGURATION ------ strUser = "<Username>" 'e.g., "cn=jimmy,cn=Users,dc=domain,dc=com" set objUser = GetObject("LDAP://" & strUser) 'declare arrays for multivalue properties arrOtherHomePhone = objUser.GetEx("otherHomePhone") arrOtherPager = objUser.GetEx("otherPager") arrOtherMobile = objUser.GetEx("otherMobile") arrOtherIpPhone = objUser.GetEx("otherIpPhone") arrOtherFax = objUser.GetEx("otherFacsimileTelephoneNumber") 'General Tab in ADU&C Wscript.Echo "First Name: " & objUser.Get("givenName") Wscript.Echo "Initials: " & objUser.Get("initials") Wscript.Echo "Last Name: " & objUser.Get("sn") Wscript.Echo "Description: " & objUser.Get("description") Wscript.Echo "Office: " & objUser.Get("physicalDeliveryOfficeName") Wscript.Echo "Telephone: " & objUser.Get("telephoneNumber") Wscript.Echo "Web Page: " & objUser.Get("wWWHomePage") 'Address Tab in ADU&C Wscript.Echo "Street Address: " & objUser.Get("streetAddress") Wscript.Echo "PO Box " & objUser.Get("postOfficeBox") Wscript.Echo "City: " & objUser.Get("l") Wscript.Echo "State/Region: " & objUser.Get("st") Wscript.Echo "Zip/Postal code: " & objUser.Get("postalCode") Wscript.Echo "Country: " & objUser.Get("co") 'Telephones Tab in ADU&C Wscript.Echo "Home Phone: " & objUser.Get("homePhone") For Each strValue in arrOtherHomePhone WScript.echo "Other Home Phone: " & strValue Next Wscript.Echo "Pager: " & objUser.Get("pager") For Each strValue in arrOtherPager WScript.echo "Other Pager: " & strValue Next Wscript.Echo "Mobile Phone: " & objUser.Get("mobile") For Each strValue in arrOtherMobile WScript.echo "Other Mobile: " & strValue Next Wscript.Echo "Fax: " & objUser.Get("facsimileTelephoneNumber") For Each strValue in arrOtherFax WScript.echo "Other Fax: " & strValue Next Wscript.Echo "IP Phone: " & objUser.Get("ipPhone") For Each strValue in arrOtherIpPhone WScript.echo "Other IP Phone: " & strValue Next Wscript.Echo "Info: " & objUser.Get("info") 'Organization Tab in ADU&C Wscript.Echo "Title: " & objUser.Get("title") Wscript.Echo "Department: " & objUser.Get("department") Wscript.Echo "Company: " & objUser.Get("company") Wscript.Echo "Manager: " & objUser.Get("manager") 'Optional Attributes Wscript.Echo "Secretary: " & objUser.Get("secretary") Wscript.Echo "Custom Attrib1: " & objUser.Get("extensionAttribute1") Wscript.Echo "Custom Attrib2: " & objUser.Get("extensionAttribute2") Wscript.Echo "Custom Attrib15: " & objUser.Get("extensionAttribute15") Discussionldifde is a useful tool to quickly export a list of object attributes from a command line, but the output is not as clean as if you write a script. By scripting your solution, you can limit your output to the subset of information you're looking for, or format the output in a more readable manner. See AlsoMS KB 237677 (Using LDIFDE to Import and Export Directory Objects to Active Directory) and MSDN: Active Directory Schema |