AD Telephone Number field name exported from VBS

G

Guest

I'm trying to create a vbs script that exports user information similar to
the lines below, but I would like to export the Telephone Number from the
General Tab of a user's properties in AD. Does anyone know what the & objUser
code is for the telephone number? I've searched the internet and tried many
different utilities (ADFIND, useraccount.vbs, listproperties.vbs) but I can't
find the field I require to output the telephone number.

str1 = "Last Login: " & objUser.LastLogin
str2 = "Last Logoff: " & objUser.LastLogoff
str3 = "Phone: " & objUser.?????
 
G

Guest

Thank you for your reply. I still fail to get any output from str3 in my
script when I insert it as follows:

str1 = "Last Login: " & objUser.LastLogin
str2 = "Last Logoff: " & objUser.LastLogoff
str3 = "Phone: " & objUser.telephoneNumber
str4 = "Logon Count: " & objUser.logonCount

When I run my script, str3 does not appear even though I have the telephone
number field filled in. Perhaps this is a bug in my AD?
 
J

Joe Richards [MVP]

I would suspect your script before I would suspect AD.

What does your bind look like?
 
G

Guest

"Bind?" Please explain.

The script I'm using is the useraccount.vbs script, and it works fine except
for the telephonenumber line.
 
J

Joe Richards [MVP]

The line with the getobject in it where you connect to the directory. Are you,
by any chance using WinNT://
 
G

Guest

Hello, I could not find what you meant by bind in the script. I'd post the
script here but it's rather long. We are using the useraccount.vbs found in
the Windows 2000 resource kit pretty much verbatim except for the
telephone.number field that I am trying to get to work.

We are on a Win2000 Advanced Server. :)
 
R

Richard Mueller [MVP]

Hi,

The variable objUser had to be created by binding (connecting) to the object
in AD, with either the WinNT or LDAP providers. For example:

Set objUser = GetObject("WinNT://MyDomain/JoeUser,user")
or
Set objUser = GetObject("LDAP://cn=Joe Smith,ou=Sales,dc=MyDomain,dc=com")

You bind with WinNT using the NT name ("pre-Windows 2000 logon name"). LDAP
requires the Distinguished Name. The telephoneNumber attribute is only
exposed by LDAP. I believe this is also true of logonCount. I have never
seen LastLogoff return a value.

Or, the script could bind to a container object, filter on users, and
enumerate the user objects, but your problem is most likely related to which
provider (WinNT or LDAP) is used to bind (make a connection to AD).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top