Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Returning a DN in VBA

15 views
Skip to first unread message

DMc2007

unread,
Feb 3, 2009, 7:43:44 AM2/3/09
to
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

Graham Mayor

unread,
Feb 3, 2009, 9:00:59 AM2/3/09
to
In what form is it stored?

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org

DMc2007

unread,
Feb 3, 2009, 9:36:54 AM2/3/09
to
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.

"Graham Mayor" <gma...@REMOVETHISmvps.org> wrote in message
news:ud$oYfghJ...@TK2MSFTNGP05.phx.gbl...

Richard Mueller [MVP]

unread,
Feb 4, 2009, 9:20:58 AM2/4/09
to

"DMc2007" <davidmcnau...@hotmail.com> wrote in message
news:B095CD47-EDCB-4C31...@microsoft.com...

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.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


Jay Freedman

unread,
Feb 4, 2009, 11:07:30 AM2/4/09
to

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


aj....@gmail.com

unread,
Apr 3, 2009, 9:38:26 AM4/3/09
to
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!

On Feb 4, 11:07 am, "Jay Freedman" <jay.freed...@verizon.net> wrote:
> Richard Mueller [MVP] wrote:

> > "DMc2007" <davidmcnaughton_1...@hotmail.com> wrote in message


> >news:B095CD47-EDCB-4C31...@microsoft.com...
> >> 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.
>
> > --
> > Richard Mueller
> > MVP Directory Services

> > Hilltop Lab -http://www.rlmueller.net


>
> 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        FAQ:http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so

> all may benefit.- Hide quoted text -
>
> - Show quoted text -

0 new messages