Click here to Skip to main content
15,909,039 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# - Email Account Verification Pin
Richard MacCutchan24-May-12 3:10
mveRichard MacCutchan24-May-12 3:10 
QuestionC# windows service.. Pin
babasateesh23-May-12 23:53
babasateesh23-May-12 23:53 
AnswerRe: C# windows service.. Pin
Ravi Bhavnani24-May-12 2:11
professionalRavi Bhavnani24-May-12 2:11 
QuestionDate filter in DataView Pin
Paul Bullimore23-May-12 22:11
Paul Bullimore23-May-12 22:11 
AnswerRe: Date filter in DataView Pin
Eddy Vluggen24-May-12 0:31
professionalEddy Vluggen24-May-12 0:31 
GeneralRe: Date filter in DataView Pin
BobJanova24-May-12 0:51
BobJanova24-May-12 0:51 
AnswerRe: Date filter in DataView Pin
Eddy Vluggen24-May-12 1:00
professionalEddy Vluggen24-May-12 1:00 
GeneralRe: Date filter in DataView Pin
Paul Bullimore24-May-12 1:46
Paul Bullimore24-May-12 1:46 
AnswerRe: Date filter in DataView Pin
Luc Pattyn24-May-12 3:01
sitebuilderLuc Pattyn24-May-12 3:01 
AnswerRe: Date filter in DataView Pin
Paul Bullimore24-May-12 21:22
Paul Bullimore24-May-12 21:22 
QuestionCan I use Font like a photoshop? Pin
Member 832808023-May-12 15:51
Member 832808023-May-12 15:51 
AnswerRe: Can I use Font like a photoshop? Pin
OriginalGriff23-May-12 19:25
mveOriginalGriff23-May-12 19:25 
GeneralThanks you for your advise. but I can't use this way. Pin
Member 832808023-May-12 23:14
Member 832808023-May-12 23:14 
GeneralRe: Thanks you for your advise. but I can't use this way. Pin
BobJanova24-May-12 0:52
BobJanova24-May-12 0:52 
GeneralRe: Thanks you for your advise. but I can't use this way. Pin
Pete O'Hanlon24-May-12 1:21
mvePete O'Hanlon24-May-12 1:21 
QuestionLooking for help querying active directory Pin
turbosupramk323-May-12 9:08
turbosupramk323-May-12 9:08 
AnswerRe: Looking for help querying active directory Pin
Dave Kreskowiak23-May-12 9:58
mveDave Kreskowiak23-May-12 9:58 
GeneralRe: Looking for help querying active directory Pin
turbosupramk323-May-12 10:23
turbosupramk323-May-12 10:23 
GeneralRe: Looking for help querying active directory Pin
Dave Kreskowiak23-May-12 12:09
mveDave Kreskowiak23-May-12 12:09 
GeneralRe: Looking for help querying active directory Pin
turbosupramk323-May-12 14:29
turbosupramk323-May-12 14:29 
AnswerRe: Looking for help querying active directory Pin
randprin24-May-12 2:16
randprin24-May-12 2:16 
GeneralRe: Looking for help querying active directory Pin
turbosupramk324-May-12 9:33
turbosupramk324-May-12 9:33 
GeneralRe: Looking for help querying active directory Pin
turbosupramk329-May-12 4:35
turbosupramk329-May-12 4:35 
Here is what I ended up using in case this comes up in a search (you'll have to change the txtbox stuff to fit your gui or console app


C#
using (var rootDirectory = new DirectoryEntry("LDAP://" + domain))//, "[user name in the directory]", "[User Password]"))
                    {
                        using (var directorySearch = new DirectorySearcher(rootDirectory))
                        {
                            if (tBoxPin.Text != "")
                            {
                                directorySearch.Filter = string.Format("(|(sAMAccountName={0}))", tBoxPin.Text);
                            }
                            if (tBoxLastName.Text != "")
                            {
                                directorySearch.Filter = string.Format("((sn={0}))", tBoxLastName.Text);

                            }
                            if (tBoxEmail.Text != "")
                            {
                                directorySearch.Filter = string.Format("((mail={0}))", tBoxEmail.Text);
                            }

                            var result = directorySearch.FindOne();

                            if (tBoxLastName.Text != "")
                            {
                                SearchResultCollection searchResults = directorySearch.FindAll();
                                foreach (SearchResult searchResult in searchResults)
                                {
                                    foreach (string propertyKey in searchResult.Properties.PropertyNames)
                                    {
                                        ResultPropertyValueCollection valueCollection = searchResult.Properties[propertyKey];
                                        ResultPropertyValueCollection accountCollection = searchResult.Properties["userprincipalname"];
                                        foreach (Object propertyValue in valueCollection)
                                        {
                                            if (propertyKey == "name")
                                            {
                                                lastNames.Add(propertyValue.ToString());
                                                if (tBoxLastName.Text != "")
                                                {
                                                    tBoxDomains.Text += (propertyValue.ToString()) + " - ";
                                                    foreach (Object account in accountCollection)
                                                    {
                                                        tBoxDomains.Text += account.ToString() + System.Environment.NewLine;
                                                        //MessageBox.Show(account.ToString());
                                                    }
                                                }
                                            }
                                        }

                                        //ResultPropertyValueCollection valueCollection = searchResult.Properties["name"];
                                        //lastNames.Add(item);
                                    }
                                }
                            }


                            //foreach (SearchResult item in searchResults)
                            //{
                            //    tBoxDomains.Text += item.Properties.PropertyNames + System.Environment.NewLine;
                            //}

                            if (lastNames.Count > 1)
                            {
                                return;
                            }

                            if (result != null)
                            {
                                DirectoryEntry myDirectoryEntry = result.GetDirectoryEntry();

                                ResultPropertyCollection myResultPropColl;
                                myResultPropColl = result.Properties;

                                foreach (string myKey in myResultPropColl.PropertyNames)
                                {

                                    if ((myKey == "samaccountname"))
                                    {
                                        foreach (Object myCollection in myResultPropColl[myKey])
                                        {
                                            tBoxPin.Text = (myCollection.ToString());
                                        }
                                    }

                                    if ((myKey == "name"))
                                    {
                                        foreach (Object myCollection in myResultPropColl[myKey])
                                        {
                                            tBoxLastName.Text = (myCollection.ToString());
                                        }
                                    }

                                    if ((myKey == "mail"))
                                    {
                                        foreach (Object myCollection in myResultPropColl[myKey])
                                        {
                                            tBoxEmail.Text = (myCollection.ToString());
                                        }
                                    }

                                    if ((myKey == "name"))
                                    {
                                        foreach (Object myCollection in myResultPropColl[myKey])
                                        {
                                            tBoxTopSecret.Text = (myCollection.ToString().ToUpper());
                                        }
                                    }

                                    if ((myKey == "homemdb"))
                                    {
                                        foreach (Object myCollection in myResultPropColl[myKey])
                                        {
                                            int delimiter = myCollection.ToString().IndexOf(",");
                                            string trimmed = myCollection.ToString();
                                            trimmed = trimmed.Remove(delimiter);
                                            trimmed = trimmed.Replace("CN=", "");
                                            tBoxExchangeServer.Text = (trimmed);
                                        }
                                    }

                                    if ((myKey == "telephonenumber"))
                                    {
                                        foreach (Object myCollection in myResultPropColl[myKey])
                                        {
                                            tBoxPhone.Text = (myCollection.ToString());
                                        }
                                    }
                                }
                            }
                        }
                    }

QuestionUsing ADWS in .Net Pin
Member 254690323-May-12 6:40
Member 254690323-May-12 6:40 
AnswerRe: Using ADWS in .Net Pin
Ravi Bhavnani23-May-12 9:33
professionalRavi Bhavnani23-May-12 9:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.