Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
QuestionNew to c# Pin
Member 19561089-Dec-16 4:14
Member 19561089-Dec-16 4:14 
AnswerRe: New to c# Pin
ZurdoDev9-Dec-16 4:54
professionalZurdoDev9-Dec-16 4:54 
AnswerRe: New to c# Pin
ZurdoDev9-Dec-16 4:55
professionalZurdoDev9-Dec-16 4:55 
AnswerRe: New to c# Pin
Eddy Vluggen9-Dec-16 7:28
professionalEddy Vluggen9-Dec-16 7:28 
AnswerRe: New to c# Pin
Gerry Schmitz9-Dec-16 8:06
mveGerry Schmitz9-Dec-16 8:06 
GeneralRe: New to c# Pin
Member 19561089-Dec-16 8:25
Member 19561089-Dec-16 8:25 
GeneralRe: New to c# Pin
Gerry Schmitz9-Dec-16 8:49
mveGerry Schmitz9-Dec-16 8:49 
QuestionError finding specific user in Active Directory Pin
Member 128939288-Dec-16 5:38
Member 128939288-Dec-16 5:38 
I am in a search for a specific user in the Active Directory, I use this method but I give me a error in the FindAll , that I have not found solve.

This is the mistake: An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System.DirectoryServices.dll




C#
SearchResultCollection sResults = null;

                try
                {
                    //modify this line to include your domain name
                    string path = "LDAP://microsistemas.com";
                    //init a directory entry
                    DirectoryEntry dEntry = new DirectoryEntry(path);

                    //init a directory searcher
                    DirectorySearcher dSearcher = new DirectorySearcher(dEntry);

                    //This line applies a filter to the search specifying a username to search for
                    //modify this line to specify a user name. if you want to search for all
                    //users who start with k - set SearchString to "k"
                    dSearcher.Filter = "(&(objectClass=user))";

                    //perform search on active directory
                    sResults = dSearcher.FindAll();

                    //loop through results of search
                    foreach (SearchResult searchResult in sResults)
                    {
                        if (searchResult.Properties["CN"][0].ToString() == "Administrator")
                        {
                            ////loop through the ad properties
                            //foreach (string propertyKey in
                            //searchResult.Properties["st"])
                            //{

                            //pull the collection of objects with this key name
                            ResultPropertyValueCollection valueCollection =
                            searchResult.Properties["manager"];

                            foreach (Object propertyValue in valueCollection)
                            {

                                //loop through the values that have a specific name
                                //an example of a property that would have multiple
                                //collections for the same name would be memberof
                                //Console.WriteLine("Property Name: " + valueCollection..ToString());
                                Console.WriteLine("Property Value: " + (string)propertyValue.ToString());

                                //["sAMAccountName"][0].ToString();
                            }
                            //}
                            Console.WriteLine(" ");
                        }
                    }
                }
                catch (InvalidOperationException iOe)
                {
                    //
                }
                catch (NotSupportedException nSe)
                {
                    //
                }
                finally
                {

                    // dispose of objects used
                    if (sResults != null)
                        sResults.Dispose();

                }
                Console.ReadLine();
            }

AnswerRe: Error finding specific user in Active Directory Pin
Nathan Minier9-Dec-16 1:34
professionalNathan Minier9-Dec-16 1:34 
QuestionLabel not getting updated. Pin
manju 37-Dec-16 21:02
manju 37-Dec-16 21:02 
AnswerRe: Label not getting updated. Pin
Richard MacCutchan7-Dec-16 21:53
mveRichard MacCutchan7-Dec-16 21:53 
AnswerRe: Label not getting updated. Pin
OriginalGriff7-Dec-16 22:01
mveOriginalGriff7-Dec-16 22:01 
AnswerRe: Label not getting updated. Pin
Michael_Davies7-Dec-16 22:54
Michael_Davies7-Dec-16 22:54 
GeneralRe: Label not getting updated. Pin
OriginalGriff7-Dec-16 23:59
mveOriginalGriff7-Dec-16 23:59 
GeneralRe: Label not getting updated. Pin
Michael_Davies8-Dec-16 0:16
Michael_Davies8-Dec-16 0:16 
GeneralRe: Label not getting updated. Pin
Richard Deeming8-Dec-16 1:50
mveRichard Deeming8-Dec-16 1:50 
GeneralRe: Label not getting updated. Pin
OriginalGriff8-Dec-16 2:28
mveOriginalGriff8-Dec-16 2:28 
GeneralRe: Label not getting updated. Pin
Dave Kreskowiak8-Dec-16 4:17
mveDave Kreskowiak8-Dec-16 4:17 
AnswerRe: Label not getting updated. Pin
V.8-Dec-16 3:44
professionalV.8-Dec-16 3:44 
Questionkinect v2 Pin
Member 128901727-Dec-16 5:07
Member 128901727-Dec-16 5:07 
AnswerRe: kinect v2 Pin
Afzaal Ahmad Zeeshan7-Dec-16 6:42
professionalAfzaal Ahmad Zeeshan7-Dec-16 6:42 
GeneralRe: kinect v2 Pin
Member 128901729-Dec-16 22:59
Member 128901729-Dec-16 22:59 
AnswerRe: kinect v2 Pin
Eddy Vluggen7-Dec-16 7:28
professionalEddy Vluggen7-Dec-16 7:28 
GeneralRe: kinect v2 Pin
Member 128901729-Dec-16 23:04
Member 128901729-Dec-16 23:04 
AnswerRe: kinect v2 Pin
Gerry Schmitz7-Dec-16 8:22
mveGerry Schmitz7-Dec-16 8:22 

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.