Solved

How do get an attribute  for the current logged on User.

Posted on 2002-06-19
5
155 Views
Last Modified: 2010-05-02
I want to get DistinguishedName attribute for the currentlly logged on user in Windows 2000 Active Directory.

What I really want is to search for the OU that the user is in. I plan to read the DN attribute as a string and then parse it for OU name .

Thanks
0
Comment
Question by:petermoh1
5 Comments
 
LVL 3

Expert Comment

by:Elmo_
ID: 7095359
Peter,

Are you just looking for the Person who is Currently Logged on?


If not could you be more specific.

Cheers,

Ed.
0
 

Author Comment

by:petermoh1
ID: 7097198
Hi ED,

I want to get the DistinguishedName attribute for the user who is currently logged in. The DistinguishedName is an attribute of the User object. This is part of a logon script where I need to map different network mappings depending on what Organisational Unit the user is in. The DistinguishedName i.e. "CN=JBLOGGS,CN=Accounts,DC=Mycompany,DC=COM" tells me which OU the user is in(Accounts).


I know how to get the current username: eg.
Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "User Name = " & WshNetwork.UserName


AND I know how to read an attribute for a user object WHEN I MANUALLY SPECIFY THE LDAP PATH: eg.

Set objUser = GetObject _
("LDAP://CN=JBLOGGS,CN=Accounts,DC=Mycompany,DC=COM")
objUser.GetInfo
strAttribute = objUser.Get("<AttributeName>")

BUT I don't know how to do this for the currently logged on user. I kind of need to merge the 2 scripts.

Thanks
0
 

Author Comment

by:petermoh1
ID: 7097239
Hi ED,

I want to get the DistinguishedName attribute for the user who is currently logged in. The DistinguishedName is an attribute of the User object. This is part of a logon script where I need to map different network mappings depending on what Organisational Unit the user is in. The DistinguishedName i.e. "CN=JBLOGGS,CN=Accounts,DC=Mycompany,DC=COM" tells me which OU the user is in(Accounts).


I know how to get the current username: eg.
Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "User Name = " & WshNetwork.UserName


AND I know how to read an attribute for a user object WHEN I MANUALLY SPECIFY THE LDAP PATH: eg.

Set objUser = GetObject _
("LDAP://CN=JBLOGGS,CN=Accounts,DC=Mycompany,DC=COM")
objUser.GetInfo
strAttribute = objUser.Get("<AttributeName>")

BUT I don't know how to do this for the currently logged on user. I kind of need to merge the 2 scripts.

Thanks
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7923638
petermoh1, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.

DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7968393
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

896 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now