public void GetEntriesByName_queryNull_throwsArgumentNullException()
 {
     var config = new ADConfiguration() {
         RootEntryUri = new Uri( "LDAP://mycopany.com/DC=mycopmany,DC=com" )
     };
     var provider = new ADPhoneBookSearchProvider( config );
     provider.GetEntriesByName( null );
 }
 public void Constructor_configSet_configSet()
 {
     var config = new ADConfiguration() {
         RootEntryUri = new Uri( "LDAP://mycopany.com/DC=mycopmany,DC=com" )
     };
     var provider = new ADPhoneBookSearchProvider( config );
     Assert.IsNotNull( provider.Configuration );
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="config">LDAP configuration object.</param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <remarks>Username and Password fields in LDAP configuration can be null (default), 
 /// if user running an application has enough priviliges to execute queries on AD.</remarks>
 public ADPhoneBookSearchProviderBase( ADConfiguration config )
 {
     if (null == config)
         throw new ArgumentNullException( "AD configuration" );
     if (null == config.RootEntryUri)
         throw new ArgumentNullException( "Root uri is not set" );
     this.Configuration = config;
     this.RootEntry = SetupRootEntryForConfiguration( this.Configuration );
 }
Esempio n. 4
0
 private static PhoneBookSearch GenerateSearcherForQueryType( 
     ADConfiguration config, Library.Enums.SearchType type)
 {
     var searcher = null as PhoneBookSearch;
     switch(type) {
         case Library.Enums.SearchType.Department:
             searcher = new PhoneBookSearch( new DepartmentADPhoneBookSearchProvider( config ) );
             break;
         case Library.Enums.SearchType.PhoneNumber:
             searcher = new PhoneBookSearch( new PhoneNumberADPhoneBookSearchProvider( config ) );
             break;
         case Library.Enums.SearchType.Name:
         default:
             searcher = new PhoneBookSearch( new NameADPhoneBookSearchProvider( config ) );
             break;
     }
     return searcher;
 }
Esempio n. 5
0
 static void Main( string[] args )
 {
     PhoneBookQuery query = null;
     try {
         var handlerArgs = new ConsolePhoneBookArgumentsHandler( args );
         query = handlerArgs.CreateQuery();
     }
     catch (Exception ex) {
         System.Console.WriteLine( "Error:\n{0}", ex.Message );
         PrintUsage();
         Environment.Exit( 0 );
     }
     if (string.IsNullOrWhiteSpace( query.StringToSearch )) {
         PrintUsage();
         Environment.Exit( 0 );
     }
     var config = new ADConfiguration() {
         RootEntryUri = new Uri( Settings.Default.AdDirectoryEntry )
     };
     var searcher = GenerateSearcherForQueryType(config, query.SearchType );
     var results = searcher.Search( query );
     PrintResultsForSearchType( results, query.SearchType );
 }
 /// <summary>
 /// Construcotr
 /// </summary>
 /// <param name="config">Configuration for directory services</param>
 public PhoneNumberADPhoneBookSearchProvider( ADConfiguration config )
     : base(config)
 {
 }
 private DirectoryEntry SetupRootEntryForConfiguration( ADConfiguration config )
 {
     var entry = new DirectoryEntry( config.RootEntryUri.OriginalString );
     if ((!string.IsNullOrWhiteSpace( config.Username )) &&
         (!string.IsNullOrWhiteSpace( config.Password ))) {
         entry.Username = config.Username;
         entry.Password = config.Password;
     }
     return entry;
 }
 /// <summary>
 /// Construcotr
 /// </summary>
 /// <param name="config">Configuration for directory services</param>
 public NameADPhoneBookSearchProvider( ADConfiguration config )
     : base(config)
 {
 }
 /// <summary>
 /// Construcotr
 /// </summary>
 /// <param name="config">Configuration for directory services</param>
 public DepartmentADPhoneBookSearchProvider( ADConfiguration config )
     : base(config)
 {
 }
 private void InitializeSearchComponents()
 {
     m_config = new ADConfiguration() {
         RootEntryUri = new Uri( Settings.Default.AdDirectoryEntry )
     };
 }