File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes Find domain for user from Active Directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Find domain for user from Active Directory" Watch "Find domain for user from Active Directory" New topic

Find domain for user from Active Directory

Bhanu Pandey

Joined: Mar 08, 2010
Posts: 1
I wrote a java code to search for users from Active Directory server.
I got the user list but dont know the domain to which user belongs.
How can the domain of the user be found from Active Directory programatically.

One method thought of is :

1)Get the distinguished name of user from Active Directory.
2)Parse the distinguished name.
3)Get the substring that starts the first instance of "DC=".
4)Strip off the "DC=" at the beginning.
5)Replace all instances of ",DC=" with a "."
6)What is left is the DNS domain name of the user.

Is this reliable.
Please suggest some other solution.
I agree. Here's the link:
subject: Find domain for user from Active Directory
Similar Threads
ADS Import User List
JNDI : Binding to an Active Directory Global Catalog with auser froma trusted Domain
Weblogic 10.3.5 & Windows 2003 Active Directory NO User but Groups
servlet querying active directory
JNDI, LDAP, & Active Directory