Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Returning a DN in VBA

Reply
 
Old 02-03-2009   #1 (permalink)
DMc2007


 
 

Returning a DN in VBA

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


My System SpecsSystem Spec
Old 02-03-2009   #2 (permalink)
Graham Mayor


 
 

Re: Returning a DN in VBA

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 wrote:
Quote:

> 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

My System SpecsSystem Spec
Old 02-03-2009   #3 (permalink)
DMc2007


 
 

Re: Returning a DN in VBA

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" <gmayor@xxxxxx> wrote in message
news:ud$oYfghJHA.4868@xxxxxx
Quote:

> 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 wrote:
Quote:

>> 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
>
>
My System SpecsSystem Spec
Old 02-04-2009   #4 (permalink)
Richard Mueller [MVP]


 
 

Re: Returning a DN in VBA


"DMc2007" <davidmcnaughton_1999@xxxxxx> wrote in message
news:B095CD47-EDCB-4C31-8064-64AFD3A427D7@xxxxxx
Quote:

> 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
--


My System SpecsSystem Spec
Old 02-04-2009   #5 (permalink)
Jay Freedman


 
 

Re: Returning a DN in VBA

Richard Mueller [MVP] wrote:
Quote:

> "DMc2007" <davidmcnaughton_1999@xxxxxx> wrote in message
> news:B095CD47-EDCB-4C31-8064-64AFD3A427D7@xxxxxx
Quote:

>> 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.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
function not returning anything PowerShell
Function returning a value VB Script
returning to a search Vista file management
Returning from RC2 to RC1 Vista General
Returning to XP, problem with spanned set Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46