Outlook Profiles: Automating Mail Signature Assignments Using Active Directory Info. Part III. Active Directory Gets Involved
April 4, 2007
What if We Will Automate it Further?
As said, semi-automatic mode is better than nothing. But still, I guess, you’ll agree here, it’s not the way we should choose if we want to achieve productivity. We need the higher level of automation. Plus we want to be as more abstracted from the user side as it possible. As we are working in Active Directory environment it is reasonable to use its abilities and retrieve the information right from the active directory database. Going that way we’ll solve two problems at once: we will free ourselves from the need to fill in info personally user-by-user and strictly assign the signature to the user according to the official information stored in the Active Directory database. That allows avoiding confusion for the user and for the customer that will contact our user.
The Approach: Querying Active Directory for an Info
As we always do when we start working with some entities, we create an object instance that will represent it. Out main goal here is to retrieve information about the user, the member of the database, and then put it down into our document. We will use ADSystemInfo object and create its instance named objSysInfo that we will us to retrieve the system info data:
Set objSysInfo = CreateObject(“ADSystemInfo”)
After that we can retrieve a distinguished name of the user that is logged on to domain and that we want to create a signature for:
strUser = objSysInfo.UserName
We are using here the UserName property that is who returns the name of the user.
Username retrieved, we can connect (bind the object) to that user account. We use GetObject method that will create a new object from the reference we are linking it to:
Set objUser = GetObject(“LDAP://” & strUser)
Note: We can also shorten the expression and just write Set objUser = GetObject(“LDAP://” & objSysInfo.UserName). Then surely we have no need to define the strUser variable.
Getting the Stuff in Our Hands
That’s the time to start working with properties. What we need them for? We need them exactly to retrieve specific information that we will use during the document filling operation.
Typically a pair that will retrieve is the full user name and the company name and is well enough to build the signature. So basically we can limit the set of information that we will retrieve to just to properties:
1. FullName, this property will return the full name of the user. That is that the name that the user would basically get in the header of the Start menu if he will click on the Start button.
Note: If you haven’t add it, open Active Directory Users and Computers snap-in and change it. See this article for an additional info.
By the way there’s a nice article describing how to make this automatically using VBScript: How to change the display names of Active Directory users with Active Directory Services Interface script
2. Company, this property will return the full name of the company.
To call them just use this form
strName = objectname.property name
Thus to retrieve the user full name, use the following expression:
strName = objUser.FullName
Correspondingly, to retrieve user company name use the expression:
strCompany = objUser.Company
Note: In fact you can overview get all off them with your own eyes if you’ll select user properties in either your contacts or using the user properties smart-tag.
Here’s how to do that:
1. Create a new e-mail.
2. Enter User Name that is recorded in Active Directory
3. Point to the typed name. The user properties smart-tag will arise in the upper left corner on the user name
4. Click on the smart-tag and select Outlook Properties
5. All these properties will be listed on the General tab of the %username% Properties dialog box
Thus you now have a clue on how to enhance the representativeness of the user mail signature. Just use the properties listed there and add them after the name of the object you used to create connection.
Thus to add user telephone number to the user signature use this expression:
strPhone = objUser.telephoneNumber
How to program Outlook
Automatic Management of Signatures Bindings and Formatting
Windows Scripting Host (WSH) Properties List
User Class Properties Reference for Windows 2000 Server and Windows Server 2003 Active Directory Schema
IADsUser Interface Property List
Reading Active Directory Object Properties in C#
Defining Object Properties of any Active Directory Schema Interface object using IADs Interface
User Object Attributes
Sue Moshers’ Solution to Create Outlook Signature using Windows Management Instrumentation (WMI) scripting
Technorati: bind object object property user class signature generate AD properties scripting host IADSUser Interface Active Directory Schema read property object model ADSI scripting active directory interface scripting WSH outlook profiles corporate signature personal signature mail signature VBScript