Recipe5.29.Retrieving Properties on User Accounts


Recipe 5.29. Retrieving Properties on User Accounts

Problem

You need to retrieve a list of properties on user accounts.

Solution

Using a graphical user interface

  1. Log on to any machine in your domain that has the Exchange management tools installed.

  2. Open the ADUC snap-in (Users and Computers.msc).

  3. Locate the container that holds the user object whose properties you want to modify.

  4. Select the user object you want to modify, then right-click it and select Properties.

  5. Select the General tab in the Properties dialog box.

  6. Edit properties as desired.

  7. Select other pages in the tabbed dialog box, and edit other properties.

  8. Click OK to close the Properties dialog box.

  9. Repeat steps 4-8 for each additional user whose properties you want to review.

Using a command-line interface

Run 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")

Discussion

ldifde 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 Also

MS KB 237677 (Using LDIFDE to Import and Export Directory Objects to Active Directory) and MSDN: Active Directory Schema



Exchange Server Cookbook
Exchange Server Cookbook: For Exchange Server 2003 and Exchange 2000 Server
ISBN: 0596007175
EAN: 2147483647
Year: 2006
Pages: 235

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net