C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Active Directory »

Connecting Active Directory


Posted Date: 12 Mar 2009    Resource Type: Code Snippets    Category: Active Directory
Author: ShankarMember Level: Diamond    
Rating: 1 out of 5Points: 10



Active Directory - AD
----
Paramters for connecting the AD

adConnectionString = “LDAP://SERVERNAME.DOMAIN1.COM:PORTNUMBER”
Domain name :domain1
Service Account :the Account available in the AD server authenticated to connect AD
Password : Password for that service account

DirectoryEntry object is used for connecting the AD.
DirectorySearcher object is used for fetching the entry from the AD.



DirectoryEntry objDirectoryEntry = new DirectoryEntry(adConnectionString, Domain name + "\\" + ServiceAccount, Password, AuthenticationTypes.Secure);
DirectorySearcher objDirectorySearcher = new DirectorySearcher(objDirectoryEntry);
SearchResult objSearchResult;


The below code will be used to filter and fetch the data from the AD.Thje filter will be used to filter the specific Organizational Unit, or a specific User, or a group
We can fetch all the data in a method FindAll.We can also fetch the indivdual user using another method called FindOne of the DirectorySearcher object.
The results fetched are assigned to another object called searchresult.
This will return null if we are not able to fetch data from the AD


objDirectorySearcher.PageSize = 1;
objDirectorySearcher.Filter = "(objectClass=*)";
objSearchResult = objDirectorySearcher.FindAll();
if (objSearchResult != null)
{

}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
SearchResult  .  FindOne  .  FindAll  .  DirectorySearcher  .  DirectoryEntry  .  Active Directory  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Active Directory
Previous Resource: Querying Information for All Drives on a System
Return to Discussion Resource Index
Post New Resource
Category: Active Directory


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use