Click here to Skip to main content
15,881,455 members
Articles / Desktop Programming / Windows Forms

Windows Services Made Simple

Rate me:
Please Sign up or sign in to vote.
4.62/5 (10 votes)
27 Jun 2007CPOL10 min read 94.3K   6.9K   69  
Describes how to build a Windows Service using the Pegasus Library.
using System;
using System.DirectoryServices;
using System.Net.Mail;

namespace Pegasus.DirectoryServices
{
	/// <summary>
	/// 
	/// </summary>
	public class DirectoryUser : DirectoryObject
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="T:DirectoryUser"/> class.
		/// </summary>
		internal DirectoryUser( DirectoryEntry entry )
		{
			AttachDirectoryEntry( entry );
		}

		/// <summary>
		/// Gets the users name.
		/// </summary>
		/// <value>The name.</value>
		public string Name
		{
			get
			{
				return GetStringProperty( "name" );
			}
		}

		/// <summary>
		/// Gets the description / title of this user.
		/// </summary>
		/// <value>The name.</value>
		public string Description
		{
			get
			{
				return GetStringProperty( "title" );
			}
		}

		/// <summary>
		/// Gets the username.
		/// </summary>
		/// <value>The username.</value>
		public string Username
		{
			get
			{
				return GetStringProperty( "sAMAccountName" );
			}
		}

		/// <summary>
		/// Gets the name of the user principal.
		/// </summary>
		/// <value>The name of the user principal.</value>
		public string UserPrincipalName
		{
			get
			{
				return GetStringProperty( "userPrincipalName" );
			}
		}

		/// <summary>
		/// Gets the user email address.
		/// </summary>
		/// <value>The mail address.</value>
		public MailAddress MailAddress
		{
			get
			{
				string email = GetStringProperty( "mail" );
				if( email != null && email.Length > 0 )
				{
					return new MailAddress( email, GetStringProperty( "name" ) );
				}

				return null;
			}
		}

		/// <summary>
		/// Gets the name of the LDAP distinguished.
		/// </summary>
		/// <value>The name of the LDAP distinguished.</value>
		public string LdapDistinguishedName
		{
			get
			{
				return GetStringProperty( "distinguishedName" );
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions