Get E-mail address from VbScript

  • Thread starter Thread starter Guillaume Genest
  • Start date Start date
G

Guillaume Genest

Hi,
We have a Windows 2000 Active Directory with Exchange
2000. What i want to do is to extract the field "e-mail"
from the main user property page from Active Directory
Users and Computers.

Is there any way to access this attribute from a vbs file
(using LDAP). Any one can provide me an example of a
script to read the e-mail address of one user.

thanks!
 
Hi Guillaume,

Thanks for your posting here.

As I know, we can use the LDIFDE and CSVDE.EXE to extract data from Active
Directory

Please refer to the following article:

Q237677 Using LDIFDE to Import/Export Directory Objects to the AD
http://support.microsoft.com/default.aspx?scid=kb;EN-US;237677

327620 HOW TO: Use Csvde to Import Contacts and User Objects into Active
http://support.microsoft.com/?id=327620

The following script is hecking for members of a Security Group "Bob Mail
Test" in an OU Mailtest in my test domain.

Set objGroup = GetObject _
("LDAP://CN=Bob Mail Test,OU=Mailtest,DC=Root,DC=com")

For Each objMember in objGroup.Members
Wscript.Echo objMember.name & VBTab & "Email Address: " &objMember.mail
Next

The output looks like the below text

D:\scripts>cscript listmember.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

CN=bob2 Email Address: (e-mail address removed)
CN=Bob Email Address: (e-mail address removed)

There are excellent scripting samples at the Microsoft Technet center. The
page you will probably find of the most interest is:

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcen
ter/user/default.asp

In addition, I recommend that you post this question to the following
newsgroup to get more information.

microsoft.public.windows.server.scripting

Thank you!

Regards,
Bob Qin
Product Support Services
Microsoft Corporation

Get Secure! - www.microsoft.com/security

====================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Guillaume,

How are things going? I am just writing in to see if you need any
assistance from me. If there is anything I can do, just feel free to let me
know.

Best regards,
Bob Qin
Product Support Services
Microsoft Corporation

Get Secure! - www.microsoft.com/security

====================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi,
I try your script sample for my situation and i always
get an error when i start the script: "A referral was
returned from the server. (line: 1, char: 1)".
Here is my script, i want mail address for member of a
security group name: MIS, in a OU TI\Operation and my
domain name is: qc.test.com.

Set objGroup = GetObject
("LDAP://CN=MIS,OU=TI,DC=qc.test.com,DC=com")

For Each objMember in objGroup.Members
Wscript.Echo objMember.name & VBTab & "Email Address: "
&objMember.mail
Next

Why it didn't work?
 
Hi Guillaume,

Please use the following script.

Set objGroup = GetObject
("LDAP://CN=MIS,OU=TI,DC=qc,DC=test,DC=com")

For Each objMember in objGroup.Members
Wscript.Echo objMember.name & VBTab & "Email Address: "
&objMember.mail
Next

Best regards,
Bob Qin
Product Support Services
Microsoft Corporation

Get Secure! - www.microsoft.com/security

====================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi,
Y try your script and i get this error on line
1: "There is no such object on the server". I try with
several groups and OU and i always get this error.

have you any idea why?
 
Hi Guillaume,

As you mentioned that you have a security group name: MIS in a OU
TI\Operation. Is the OU's name TI? or Operation? or "TI\Operation"?

In addition, please open Active Directory Users and Computers, locate the
MIS group. Perform a screen capture.
Open "ADSI Edit", expand Domain NC and locate the MIS group. Perform a
screen capture.

Now please attach the two screen capture pictures in your posts and I will
do more research.

Thank you,

Bob Qin
Product Support Services
Microsoft Corporation

Get Secure! - www.microsoft.com/security

====================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Ok Thanks.

In fact users from security groups: "MIS" are in
OU "Operation". the OU "Operation" is under the OU "TI"
but the security groups himself is not in this OU, but
users member of this security groups are.

I try replacing OU=operation by OU=Users because MIS
security groups are in Users OU.
but i still have the same error.

I cannot attach image to the post.. please give me your
mail address and i will send you the print screen.

thanks
 
Please try

("LDAP://CN=MIS,OU=TI,OU=Operation,DC=qc,DC=test,DC=com")

Then try the following command in DOS prompt.

cscript listmember.vbs

If the problem still persists, please send the screen captures to
(e-mail address removed).

Thank you,

Bob Qin
Product Support Services
Microsoft Corporation

Get Secure! - www.microsoft.com/security

====================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Back
Top