Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Find domain for user from Active Directory

 
Bhanu Pandey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic