[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How can I read these user attributes? (VBScript & ADSI)

Posted on 2002-06-24
3
Medium Priority
?
345 Views
Last Modified: 2012-06-27
Answers to ANY of the following will get full points:

(Note I am using VBScript on Windows 2000 Active Directory so I think the answer will involve ADSI.)

1. How do I get the GUID for the currently logged on user?
or...
2. How do I get the CN attribute for the currently logged on user?
or...
2. How do I get the distinguishedName attribute for the currently logged on user?
or...
3. How do I find which Organisational Unit the currently logged on user is in?

0
Comment
Question by:chrismoh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Brendt Hess earned 300 total points
ID: 7105851
This *should* get you the distinguishedName attribute:

Set oConnection = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
oConnection.Provider = "ADsDSOObject")
oConnection.Open "Active Directory Provider"
Set oCommand.ActiveConnection = oConnection
Set oRoot = GetObject("LDAP://RootDSE")
sDomain = oRoot.Get("DefaultNamingContext")

Set oNet = CreateObject("Wscript.Network")
sUserID = ""
On Error Resume Next
Do While sUserID = ""
  Wscript.Sleep 5
  sUserID = oNet.UserName
Loop
On Error Goto 0

sQuery = "SELECT distinguishedName FROM 'LDAP://" & _
  sDomain & "' WHERE sAMAccountName = '" & sUserID & "'"
oCommand.CommandText = sQuery

Set oResults = oCommand.Execute
sDN = oResults.Fields("distinguishedName")
0
 

Author Comment

by:chrismoh
ID: 7105909
Thanks bhess1, it took me 2 days and 3 question submissions to get an that works.
If I had more points I'd give them to you.
0
 
LVL 32

Expert Comment

by:Brendt Hess
ID: 7105918
Glad that I could help.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question