Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Dear Friends,
 
Please Help Me.
 
I need to get the SAMAccountName by checking with description.
 
I will get employeeID from Oracle db with that employeeID i need toget the ActiveDirectory Username
 
Thanks in Advance
Sanju
Posted 20-Jun-12 23:56pm
Edited 1-Jul-12 23:40pm
v3
Comments
Bernhard Hiller at 21-Jun-12 6:41am
   
? That's a very strange way to do things. Are you sure?
I'd rather expect to get a username from the Oracle database with the help of the employeeID, and then use that username to authenticate the user against the Active Directory...
Sanju TV at 21-Jun-12 7:12am
   
Thanks for your reply..
 
I am also not sure that this will work but my client has put up this requirement.
 
rest all things i finished nw stuck on this point.
 
So u mean to say its impossible..?
 
Sanju
ryanb31 at 21-Jun-12 7:55am
   
Look into querying Active Directory using LDAP.
Sanju TV at 21-Jun-12 8:43am
   
how to query into Active directory
i checked any sample u have ..
ryanb31 at 21-Jun-12 8:44am
   
Samples are on the internet. Maybe start here, http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

DirectoryEntry objDE = new DirectoryEntry("LDAP://XXXX", "UserLogin", "User Password");
            using (objDE)
            {
                DirectorySearcher objDSearcher = new DirectorySearcher();
                objDSearcher.SearchRoot = objDE;
                objDSearcher.PropertiesToLoad.Add("department");
                objDSearcher.PropertiesToLoad.Add("title");
                objDSearcher.PropertiesToLoad.Add("cn");
 
                objDSearcher.PropertiesToLoad.Add("SAMAccountName");
                objDSearcher.PropertiesToLoad.Add("givenname");
 
                objDSearcher.PropertiesToLoad.Add("sn");
                objDSearcher.PropertiesToLoad.Add("memberOf");
 
                objDSearcher.PropertiesToLoad.Add("department");
                objDSearcher.PropertiesToLoad.Add("title");
 
                objDSearcher.PropertiesToLoad.Add("postalCode");
                objDSearcher.PropertiesToLoad.Add("streetAddress");
 
                objDSearcher.PropertiesToLoad.Add("st");
                objDSearcher.PropertiesToLoad.Add("telephoneNumber");
 
                objDSearcher.PropertiesToLoad.Add("l");
                objDSearcher.PropertiesToLoad.Add("mail");
 
                objDSearcher.Filter = "(SAMAccountName=XXXXXXXXXX)";
 
                objDSearcher.SearchScope = SearchScope.Subtree;
                try
                {
                    SearchResultCollection result = objDSearcher.FindAll();
                    foreach (SearchResult sr in result)
                    {
 
                        Response.Write("ID:" + sr.Properties["SAMAccountName"][0].ToString() + "<br/>");
                        Response.Write("ID:" + sr.Properties["givenname"][0].ToString() + "<br/>");
                        Response.Write("ID:" + sr.Properties["cn"][0].ToString() + "<br/>");
                        Response.Write("Department:" + sr.Properties["Department"][0].ToString() + "<br/>");
                        Response.Write("title:" + sr.Properties["title"][0].ToString() + "<br/>");
                        Response.Write("------------------------------------------------------------------------<br/>");
                    }
                }
                catch (System.DirectoryServices.DirectoryServicesCOMException ex)
                {
                    Response.Write(ex.Message);
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
  Permalink  
Comments
Sanju TV at 3-Jul-12 8:51am
   
Thank You
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Friends,
Thanks for your help
 
i solved the problem i got solution from this below link.
My Solved Code
 

 
Thanks
Sanju
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100