Returning a DN in VBA

D

DMc2007

Hi

How can I return a Users DN (distinghised Name) that is stored in Active
Directory using VBA in Microsoft Office Word 2003.

Regards

D
 
G

Graham Mayor

In what form is it stored?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

DMc2007

basically it is part of Active Directory, when you log on to a windows
domain, it is used to identify who the user is and what OU or Organizational
Unit that person belongs to.
 
R

Richard Mueller [MVP]

DMc2007 said:
Hi

How can I return a Users DN (distinghised Name) that is stored in Active
Directory using VBA in Microsoft Office Word 2003.

Regards

D

The standard method is to use the ADSystemInfo object. The UserName
attribute of the object is the DN of the current user:
=====
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName
========
An error is raised if the user is not authenticated to a domain. In VB you
must add a reference to "Active DS Type Library" (which is activeds.tlb).
I've never done this in VBA.
 
J

Jay Freedman

Richard said:
The standard method is to use the ADSystemInfo object. The UserName
attribute of the object is the DN of the current user:
=====
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName
========
An error is raised if the user is not authenticated to a domain. In
VB you must add a reference to "Active DS Type Library" (which is
activeds.tlb). I've never done this in VBA.

It does work in VBA. Also, once you've added the reference to the ADS
library, you can use early binding, which gives you IntelliSense support.

Sub x()
Dim objSysInfo As ADSystemInfo
Dim strUserDN As String
Set objSysInfo = New ADSystemInfo
strUserDN = objSysInfo.UserName
MsgBox strUserDN
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
A

aj.nahr

I'm looking at doing something similar, but I want to prompt for which
user info to pull so it can be automatically entered into a letterhead
form the info in AD.
Is that possible?
Thanks!
 

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