Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchmoser committed Dec 11, 2020
1 parent d152a14 commit f7c9a2b
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions SharpLDAPSearch/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Text;

namespace SharpLDAPSearch
{
Expand Down Expand Up @@ -35,8 +33,6 @@ static void Main(string[] args)
Environment.Exit(0);
}

//string[] searchProperties = { "name" };

mySearcher.SizeLimit = int.MaxValue;
mySearcher.PageSize = int.MaxValue;

Expand All @@ -48,38 +44,27 @@ static void Main(string[] args)
// Get the properties of the 'mySearchResult'.
ResultPropertyCollection myResultPropColl;
myResultPropColl = mySearchResult.Properties;
foreach (string myKey in myResultPropColl.PropertyNames)

// return only specified fields
if (searchProperties.Count > 0)
{
if (searchProperties.Count > 0)
foreach (string attr in searchProperties)
{
if (searchProperties.Contains(myKey.ToString().ToLower()))
{
foreach (Object myCollection in myResultPropColl[myKey])
{
Console.WriteLine("{0} - {1}", myKey, myCollection);
}
}
}
else
{
foreach (Object myCollection in myResultPropColl[myKey])
{
Console.WriteLine("{0} - {1}", myKey, myCollection);
}
Console.WriteLine(mySearchResult.Properties[attr][0].ToString());
}
}
/*
foreach (string myKey in myResultPropColl.PropertyNames)
// if no fields specified, return all
else
{
if (searchProperties.Contains(myKey.ToString().ToLower()))
foreach (string myKey in myResultPropColl.PropertyNames)
{
foreach (Object myCollection in myResultPropColl[myKey])
{
Console.WriteLine("{0} - {1}", myKey, myCollection);
}
}
}
*/

mySearcher.Dispose();
entry.Dispose(); ;
}
Expand Down

0 comments on commit f7c9a2b

Please sign in to comment.