This is the first of my series about SharePoint Managed Account, this feature is newly introduced in SharePoint 2010. SharePoint Managed Account feature now enable us to easily manage the User accounts by means of  password changing and notification for password change and automatic password reset.

And also used for Configuring and mapping different accounts with different services and Web Applications. Without registering the account, we can’t create a Service application and Web Applications.

In this post I am giving the snippet for retrieving the list of registered managed account users from the Farm.

SPFarm farm = SPFarm.Local;
SPFarmManagedAccountCollection accounts = new SPFarmManagedAccountCollection(farm);
foreach (SPManagedAccount account in accounts)
{
    Console.Write(account.Username);
}

SPFarmManagedAccountCollection returns the available managed accounts from the given farm.

SPManagedAccount has the list of properties of the registered account. By using those properties we can set the password reset schedule, etc..

Here I am just displaying only Username property of the Registered Account.

Coming posts I’ll come up with an interesting stuff with Managed Accounts, Stay tune my blog…