Link to home
Start Free TrialLog in
Avatar of D B
D BFlag for United States of America

asked on

Get a users name (last and first) from logon ID

I have an application that allows an administrator to add authorized users. They enter the user ID used to log into Windows, along with the user's first and last name.

I am certain there is probably a way to validate the userid and return the name, because when you set up a shared drive on your own computer, you can add the user ID, and click [Check Names] button and it will return the name. For example, I enter my ID (dbb####) and click Check Names and it returns "Douglas B Bishop (dbb####@domain.Intranet)".
Is there some way I can emulate this operation in VB.Net (2005), where I pass a userid (and possibly domain name) and it returns the name?

I would also like to use this method to iterate through the users who have been set up and be able to validate tha it is still a valid userid (i.e. the employee has not left the company) as users are spread out all over the country.

Thanks for the help.
Avatar of ratstud
ratstud

You will have to do LDAP queries to the active directory to get these attributes from the userid... hope this helps point you in the right direction.
ASKER CERTIFIED SOLUTION
Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of D B

ASKER

tgerbert: I thought I was in heaven for a moment. I copied this code, but am getting the following error:

Namespace or type specified in the Imports 'System.DirectoryServices' doesn't contain any public
member or cannot be found. Make sure the namespace or the type is defined and contains at least one
public member. Make sure the imported element name doesn't use any aliases.

Open in new window


Any suggestions?
Avatar of D B

ASKER

Got it going. Added a reference to it. Thanks.
Avatar of D B

ASKER

I have been looking everywhere for information about the properties of the DirectoryEntry object. From this sample, I know that "givenName" is the first name and "sn" is the last name. What other properties are available (for instance, location or phone number, etc. These would be valuable for tracking down an employee if there were questions. I could build in a functin where the administrator could double-click on an entry and I could bring up information regarding them.
Avatar of D B

ASKER

If you can just point me to a link that gives the properties, that would be great. Thanks.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial