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 - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
"Graham Mayor" <gma...@REMOVETHISmvps.org> wrote in message
news:ud$oYfghJ...@TK2MSFTNGP05.phx.gbl...
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.
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 -