Subscribe to Windows IT Pro
July 29, 2009 12:00 AM

What’s Your Computer Name?

Extend the AD schema to store and find useful information
Windows IT Pro
InstantDoc ID #102347
Rating: (2)
PROBLEM: Determining a computer's name can be difficult if you have to rely on user input.

SOLUTION: Add a new property to the built-in Active Directory User object to store the last computer the user logged on to.

REQUIREMENTS:
1.  Windows 2003 domain (native, or mixed Windows 2000 mode)

2. Windows XP clients

3. OIDgen.vbs

4. MMC Active Directory Schema snap-in

5. ADSIEdit.msc

6. Text editor (I recommend Notepad++ because it performs keyword highlighting for Visual Basic—notepad-plus.sourceforge.net/uk/site.htm)

7. Logon scripts UpdateITUserInfo.vbs and DisplayITUserInfo.vbs

DIFFICULTY: 4 out of 5

SOLUTION STEPS:

1. Add a property (e.g., contosocom-LastComputer) to the built-in User object in Active Directory to store the last computer the user logged on to.

2. Add a logon script that updates the property every time the user logs on.

3. Grant all users permission to update the property.

4. Add a context menu to the User object that runs a script to retrieve and display the property.

During all my years of IT support, I can't tell you how many times I've asked a user, "What's your computer name?" only to be greeted with dumbfounded silence. And obtaining the answer to this question can be like pulling teeth. Do you tell the user to right-click My Computer, select Properties, then click the Computer Name tab? Not everyone keeps the My Computer icon on the desktop—and I've talked to many users who don't know what "right-click" means. What about typing ECHO %COMPUTERNAME% at a command prompt? This approach often isn't worth the effort—just getting a user to type cmd in the Run box can be frustrating.

Knowing a user's computer name is important for checking event logs, copying files to the C$ share, or examining the registry. And in a large organization, the faster you can obtain this information—without requiring user input—the better. I figured Active Directory (AD) would be the perfect place to store such information: You could obtain a computer name anytime without having to ask the user.

Of course, extending AD with custom attributes isn't high on any administrator's list of things to do, because you can't delete any class or attribute that you create. However, you can use the Microsoft Management Console (MMC) Active Directory Schema snap-in to disable classes and attributes. Once you disable a class or attribute, it's like it never existed.

In this article I explain how to create custom AD attributes that will let you find useful information. You'll be able to search AD for computer names and return the name of the user who last logged on. In addition, you'll be able to right-click a username in the MMC Active Directory Users and Computers snap-in and open a Computer Management snap-in for the computer the user last logged on to.

Generating the Base OID
Before you can create custom attributes or classes, you need your own Object Identifier (OID). An OID is the unique identifier that will be the base ID of all your attributes and classes. The reason you need your own OID is to make sure no conflicts occur when software packages try to extend the schema. For example, Microsoft Exchange adds numerous classes and objects to AD's schema, each with their own OIDs. If you try to use an OID that Exchange uses, you'll run into problems.

Related Content:

ARTICLE TOOLS

Comments
  • Jeff
    3 years ago
    Sep 06, 2009

    Clever, and interesting reading, too. I'm not sure I'd want to take this project on, but it's definitely functionality that should be built in to AD.

    I'd also need it to return a list of at least 2 of the most-recently-logged-on computers. Almost all my users are log on to their workstations, first, and from there into an RDP session, to run a LOB app. So most of my results would show the name of a Terminal Server which may or may not be where the problem is.

  • Stephen
    3 years ago
    Aug 05, 2009

    Aaron,
    What are you thnking? You know this is not a good idea - you even admit that in paragraph 3 about the reluctance to modify the AD scheme. Disabling is not "like it never existed" and you know it.

    How did anyone distribute computers in an Enterprise without entering the data in their asset tracker? You should record the MAC addresses and configure the computer names before deployment. Have a standard naming convention and stick to it. Don't let users change it.

    Other options:
    1. Have them meet you on a web-sharing site and take control. You can even use remote assistance.
    2. Have a URL that only prints the incoming IP address. Tell the user to enter it (for example: http://myip.mydomain.com) on the Intranet.
    3. Deploy a small agent to all enterprise systems that reports back system info to a asset repository

    There are lots of useful tools and free software to get this to work without modifying AD. An unused OID today may be registered tomorrow. This is just unsound advice. An admin working for me that did this type of activity would find themselves in the unemployment line very soon.

    You can find the last logged in user using the security logs which you can send to a syslog device. Again, there are free tools around to collect, sort and filter this information.

    Let's get admins using available tools and technology rather than building new customized things that can go horribly wrong.

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.