Loading ...
Sorry, an error occurred while loading the content.

Re: Object Reference with DirectorySearcher FindOne() Method

Expand Messages
  • tarakvbhatt
    Hello Joe, ... at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.Move Next() r n at System.DirectoryServices.DirectorySearcher.FindOne()
    Message 1 of 11 , Feb 1, 2007
    • 0 Attachment
      Hello Joe,

      Here is the stack trace of the error :

      ---------------------------------------------------
      at
      System.DirectoryServices.SearchResultCollection.ResultsEnumerator.Move
      Next()\r\n at System.DirectoryServices.DirectorySearcher.FindOne()
      \r\n at ActiveDirectoryUtilities.ADUtil.GetUserInfo(String
      username) in c:\\Tarak\\Projects\\App_Code\\ADUtil.cs:line 207

      ----------------------------------------------------

      Thanks & Regards,
      Tarak.


      --- In ADSIANDDirectoryServices@yahoogroups.com, "Joe Kaplan"
      <joe@...> wrote:
      >
      > Can you show the full stack trace of the error? Also, what is the
      value you
      > are using for the LDAP path?
      >
      > Joe K.
      >
      > ----- Original Message -----
      > From: "tarakvbhatt" <tarak.bhatt@...>
      > To: <ADSIANDDirectoryServices@yahoogroups.com>
      > Sent: Wednesday, January 31, 2007 12:10 AM
      > Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher
      FindOne()
      > Method
      >
      >
      >
      > Hello Joe,
      >
      > Here is the code :
      > -----------------------------------------------------------------
      > DirectoryEntry de = new DirectoryEntry(usersLdapPath, adLoginName,
      > adLoginPassword);
      >
      > DirectorySearcher ds = new DirectorySearcher(de);
      >
      > ds.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))
      > (objectCategory=user)(sAMAccountName=" + username + "))";
      >
      > ds.SearchScope = SearchScope.Subtree;
      >
      > ds.PropertiesToLoad.Add("cn");
      >
      > SearchResult r = ds.FindOne();
      >
      > -----------------------------------------------------------------
      >
      > I am getting error in last sentence.
      > ( i.e. at ---> SearchResult r = ds.FindOne(); )
      >
      > It works well when I run the application from my developing machine
      > (where OS is Windows XP).
      >
      > It only gives RANDOM problem of "Object reference not set to an
      > instance of an object" when I run the application from the server
      > (where OS is Windows Server 2003).
      >
      > Thanks for your support.
      >
      > Regards,
      > Tarak.
      >
    • Joe Kaplan
      That s definitely not a good thing. There is something wrong in the guts of the SearchResultCollection that isn t working correctly. I have no idea what s
      Message 2 of 11 , Feb 1, 2007
      • 0 Attachment
        That's definitely not a good thing. There is something wrong in the guts of
        the SearchResultCollection that isn't working correctly. I have no idea
        what's wrong, but it may be necessary to report this to Microsoft to get a
        diagnosis.

        If you could reprint the complete code sample that demonstrates the problem
        here, I could try to replicate it myself.

        Out of curiosity, do you get different results if you change the filter?

        Joe K.

        ----- Original Message -----
        From: "tarakvbhatt" <tarak.bhatt@...>
        To: <ADSIANDDirectoryServices@yahoogroups.com>
        Sent: Thursday, February 01, 2007 3:34 AM
        Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher FindOne()
        Method



        Hello Joe,

        Here is the stack trace of the error :

        ---------------------------------------------------
        at
        System.DirectoryServices.SearchResultCollection.ResultsEnumerator.Move
        Next()\r\n at System.DirectoryServices.DirectorySearcher.FindOne()
        \r\n at ActiveDirectoryUtilities.ADUtil.GetUserInfo(String
        username) in c:\\Tarak\\Projects\\App_Code\\ADUtil.cs:line 207

        ----------------------------------------------------

        Thanks & Regards,
        Tarak.


        --- In ADSIANDDirectoryServices@yahoogroups.com, "Joe Kaplan"
        <joe@...> wrote:
        >
        > Can you show the full stack trace of the error? Also, what is the
        value you
        > are using for the LDAP path?
        >
        > Joe K.
        >
        > ----- Original Message -----
        > From: "tarakvbhatt" <tarak.bhatt@...>
        > To: <ADSIANDDirectoryServices@yahoogroups.com>
        > Sent: Wednesday, January 31, 2007 12:10 AM
        > Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher
        FindOne()
        > Method
        >
        >
        >
        > Hello Joe,
        >
        > Here is the code :
        > -----------------------------------------------------------------
        > DirectoryEntry de = new DirectoryEntry(usersLdapPath, adLoginName,
        > adLoginPassword);
        >
        > DirectorySearcher ds = new DirectorySearcher(de);
        >
        > ds.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))
        > (objectCategory=user)(sAMAccountName=" + username + "))";
        >
        > ds.SearchScope = SearchScope.Subtree;
        >
        > ds.PropertiesToLoad.Add("cn");
        >
        > SearchResult r = ds.FindOne();
        >
        > -----------------------------------------------------------------
        >
        > I am getting error in last sentence.
        > ( i.e. at ---> SearchResult r = ds.FindOne(); )
        >
        > It works well when I run the application from my developing machine
        > (where OS is Windows XP).
        >
        > It only gives RANDOM problem of "Object reference not set to an
        > instance of an object" when I run the application from the server
        > (where OS is Windows Server 2003).
        >
        > Thanks for your support.
        >
        > Regards,
        > Tarak.
        >
      • tarakvbhatt
        Hello Joe, ... public void GetUserInfo(string username) { DirectoryEntry de = new DirectoryEntry(usersLdapPath, adLoginName, adLoginPassword);
        Message 3 of 11 , Feb 2, 2007
        • 0 Attachment
          Hello Joe,

          Here is the code :
          -----------------------------------------------------------

          public void GetUserInfo(string username)
          {

          DirectoryEntry de = new DirectoryEntry(usersLdapPath, adLoginName,
          adLoginPassword);
          DirectorySearcher ds = new DirectorySearcher(de);

          try
          {
          ds.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))
          (objectCategory=user)(sAMAccountName=" + username + "))";

          ds.SearchScope = SearchScope.Subtree;

          ds.PropertiesToLoad.Add("cn");

          SearchResult r = ds.FindOne();

          -----------------------------------------------------------

          The last sentence gives the error.
          But please keep in mind that the error is RANDOM.
          i.e. it never occurs from my development machine.
          But RANDOMly it comes on WIN2003 Server machine.

          Thanks & Regards,

          Tarak.


          --- In ADSIANDDirectoryServices@yahoogroups.com, "Joe Kaplan"
          <joe@...> wrote:
          >
          > That's definitely not a good thing. There is something wrong in
          the guts of
          > the SearchResultCollection that isn't working correctly. I have no
          idea
          > what's wrong, but it may be necessary to report this to Microsoft
          to get a
          > diagnosis.
          >
          > If you could reprint the complete code sample that demonstrates the
          problem
          > here, I could try to replicate it myself.
          >
          > Out of curiosity, do you get different results if you change the
          filter?
          >
          > Joe K.
          >
          > ----- Original Message -----
          > From: "tarakvbhatt" <tarak.bhatt@...>
          > To: <ADSIANDDirectoryServices@yahoogroups.com>
          > Sent: Thursday, February 01, 2007 3:34 AM
          > Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher
          FindOne()
          > Method
          >
          >
          >
          > Hello Joe,
          >
          > Here is the stack trace of the error :
          >
          > ---------------------------------------------------
          > at
          >
          System.DirectoryServices.SearchResultCollection.ResultsEnumerator.Move
          > Next()\r\n at System.DirectoryServices.DirectorySearcher.FindOne()
          > \r\n at ActiveDirectoryUtilities.ADUtil.GetUserInfo(String
          > username) in c:\\Tarak\\Projects\\App_Code\\ADUtil.cs:line 207
          >
          > ----------------------------------------------------
          >
          > Thanks & Regards,
          > Tarak.
          >
          >
          > --- In ADSIANDDirectoryServices@yahoogroups.com, "Joe Kaplan"
          > <joe@> wrote:
          > >
          > > Can you show the full stack trace of the error? Also, what is the
          > value you
          > > are using for the LDAP path?
          > >
          > > Joe K.
          > >
          > > ----- Original Message -----
          > > From: "tarakvbhatt" <tarak.bhatt@>
          > > To: <ADSIANDDirectoryServices@yahoogroups.com>
          > > Sent: Wednesday, January 31, 2007 12:10 AM
          > > Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher
          > FindOne()
          > > Method
          > >
          > >
          > >
          > > Hello Joe,
          > >
          > > Here is the code :
          > > -----------------------------------------------------------------
          > > DirectoryEntry de = new DirectoryEntry(usersLdapPath, adLoginName,
          > > adLoginPassword);
          > >
          > > DirectorySearcher ds = new DirectorySearcher(de);
          > >
          > > ds.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))
          > > (objectCategory=user)(sAMAccountName=" + username + "))";
          > >
          > > ds.SearchScope = SearchScope.Subtree;
          > >
          > > ds.PropertiesToLoad.Add("cn");
          > >
          > > SearchResult r = ds.FindOne();
          > >
          > > -----------------------------------------------------------------
          > >
          > > I am getting error in last sentence.
          > > ( i.e. at ---> SearchResult r = ds.FindOne(); )
          > >
          > > It works well when I run the application from my developing
          machine
          > > (where OS is Windows XP).
          > >
          > > It only gives RANDOM problem of "Object reference not set to an
          > > instance of an object" when I run the application from the server
          > > (where OS is Windows Server 2003).
          > >
          > > Thanks for your support.
          > >
          > > Regards,
          > > Tarak.
          > >
          >
        • Joe Kaplan
          Can you also show what the LDAP path looks like that you are using? I don t need your credentials, just a path example. Joe K. ... From: tarakvbhatt
          Message 4 of 11 , Feb 2, 2007
          • 0 Attachment
            Can you also show what the LDAP path looks like that you are using? I don't
            need your credentials, just a path example.

            Joe K.

            ----- Original Message -----
            From: "tarakvbhatt" <tarakvbhatt2003@...>
            To: <ADSIANDDirectoryServices@yahoogroups.com>
            Sent: Friday, February 02, 2007 7:17 AM
            Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher FindOne()
            Method



            Hello Joe,

            Here is the code :
            -----------------------------------------------------------

            public void GetUserInfo(string username)
            {

            DirectoryEntry de = new DirectoryEntry(usersLdapPath, adLoginName,
            adLoginPassword);
            DirectorySearcher ds = new DirectorySearcher(de);

            try
            {
            ds.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))
            (objectCategory=user)(sAMAccountName=" + username + "))";

            ds.SearchScope = SearchScope.Subtree;

            ds.PropertiesToLoad.Add("cn");

            SearchResult r = ds.FindOne();

            -----------------------------------------------------------

            The last sentence gives the error.
            But please keep in mind that the error is RANDOM.
            i.e. it never occurs from my development machine.
            But RANDOMly it comes on WIN2003 Server machine.

            Thanks & Regards,

            Tarak.


            --- In ADSIANDDirectoryServices@yahoogroups.com, "Joe Kaplan"
            <joe@...> wrote:
            >
            > That's definitely not a good thing. There is something wrong in
            the guts of
            > the SearchResultCollection that isn't working correctly. I have no
            idea
            > what's wrong, but it may be necessary to report this to Microsoft
            to get a
            > diagnosis.
            >
            > If you could reprint the complete code sample that demonstrates the
            problem
            > here, I could try to replicate it myself.
            >
            > Out of curiosity, do you get different results if you change the
            filter?
            >
            > Joe K.
            >
            > ----- Original Message -----
            > From: "tarakvbhatt" <tarak.bhatt@...>
            > To: <ADSIANDDirectoryServices@yahoogroups.com>
            > Sent: Thursday, February 01, 2007 3:34 AM
            > Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher
            FindOne()
            > Method
            >
            >
            >
            > Hello Joe,
            >
            > Here is the stack trace of the error :
            >
            > ---------------------------------------------------
            > at
            >
            System.DirectoryServices.SearchResultCollection.ResultsEnumerator.Move
            > Next()\r\n at System.DirectoryServices.DirectorySearcher.FindOne()
            > \r\n at ActiveDirectoryUtilities.ADUtil.GetUserInfo(String
            > username) in c:\\Tarak\\Projects\\App_Code\\ADUtil.cs:line 207
            >
            > ----------------------------------------------------
            >
            > Thanks & Regards,
            > Tarak.
            >
            >
            > --- In ADSIANDDirectoryServices@yahoogroups.com, "Joe Kaplan"
            > <joe@> wrote:
            > >
            > > Can you show the full stack trace of the error? Also, what is the
            > value you
            > > are using for the LDAP path?
            > >
            > > Joe K.
            > >
            > > ----- Original Message -----
            > > From: "tarakvbhatt" <tarak.bhatt@>
            > > To: <ADSIANDDirectoryServices@yahoogroups.com>
            > > Sent: Wednesday, January 31, 2007 12:10 AM
            > > Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher
            > FindOne()
            > > Method
            > >
            > >
            > >
            > > Hello Joe,
            > >
            > > Here is the code :
            > > -----------------------------------------------------------------
            > > DirectoryEntry de = new DirectoryEntry(usersLdapPath, adLoginName,
            > > adLoginPassword);
            > >
            > > DirectorySearcher ds = new DirectorySearcher(de);
            > >
            > > ds.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))
            > > (objectCategory=user)(sAMAccountName=" + username + "))";
            > >
            > > ds.SearchScope = SearchScope.Subtree;
            > >
            > > ds.PropertiesToLoad.Add("cn");
            > >
            > > SearchResult r = ds.FindOne();
            > >
            > > -----------------------------------------------------------------
            > >
            > > I am getting error in last sentence.
            > > ( i.e. at ---> SearchResult r = ds.FindOne(); )
            > >
            > > It works well when I run the application from my developing
            machine
            > > (where OS is Windows XP).
            > >
            > > It only gives RANDOM problem of "Object reference not set to an
            > > instance of an object" when I run the application from the server
            > > (where OS is Windows Server 2003).
            > >
            > > Thanks for your support.
            > >
            > > Regards,
            > > Tarak.
            > >
            >
          • Ryan Dunn
            Are you or another process doing something on the machine at the same time... like deleting users with the UI? ... [Non-text portions of this message have been
            Message 5 of 11 , Feb 2, 2007
            • 0 Attachment
              Are you or another process doing something on the machine at the same
              time... like deleting users with the UI?

              On 2/2/07, Joe Kaplan <joe@...> wrote:
              >
              > Can you also show what the LDAP path looks like that you are using? I
              > don't
              > need your credentials, just a path example.
              >
              > Joe K.
              >
              > ----- Original Message -----
              > From: "tarakvbhatt" <tarakvbhatt2003@...<tarakvbhatt2003%40hotmail.com>
              > >
              > To: <ADSIANDDirectoryServices@yahoogroups.com<ADSIANDDirectoryServices%40yahoogroups.com>
              > >
              > Sent: Friday, February 02, 2007 7:17 AM
              > Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher
              > FindOne()
              > Method
              >
              > Hello Joe,
              >
              > Here is the code :
              > ----------------------------------------------------------
              >
              > public void GetUserInfo(string username)
              > {
              >
              > DirectoryEntry de = new DirectoryEntry(usersLdapPath, adLoginName,
              > adLoginPassword);
              > DirectorySearcher ds = new DirectorySearcher(de);
              >
              > try
              > {
              > ds.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))
              > (objectCategory=user)(sAMAccountName=" + username + "))";
              >
              > ds.SearchScope = SearchScope.Subtree;
              >
              > ds.PropertiesToLoad.Add("cn");
              >
              > SearchResult r = ds.FindOne();
              >
              > ----------------------------------------------------------
              >
              > The last sentence gives the error.
              > But please keep in mind that the error is RANDOM.
              > i.e. it never occurs from my development machine.
              > But RANDOMly it comes on WIN2003 Server machine.
              >
              > Thanks & Regards,
              >
              > Tarak.
              >
              > --- In ADSIANDDirectoryServices@yahoogroups.com<ADSIANDDirectoryServices%40yahoogroups.com>,
              > "Joe Kaplan"
              > <joe@...> wrote:
              > >
              > > That's definitely not a good thing. There is something wrong in
              > the guts of
              > > the SearchResultCollection that isn't working correctly. I have no
              > idea
              > > what's wrong, but it may be necessary to report this to Microsoft
              > to get a
              > > diagnosis.
              > >
              > > If you could reprint the complete code sample that demonstrates the
              > problem
              > > here, I could try to replicate it myself.
              > >
              > > Out of curiosity, do you get different results if you change the
              > filter?
              > >
              > > Joe K.
              > >
              > > ----- Original Message -----
              > > From: "tarakvbhatt" <tarak.bhatt@...>
              > > To: <ADSIANDDirectoryServices@yahoogroups.com<ADSIANDDirectoryServices%40yahoogroups.com>
              > >
              > > Sent: Thursday, February 01, 2007 3:34 AM
              > > Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher
              > FindOne()
              > > Method
              > >
              > >
              > >
              > > Hello Joe,
              > >
              > > Here is the stack trace of the error :
              > >
              > > ---------------------------------------------------
              > > at
              > >
              > System.DirectoryServices.SearchResultCollection.ResultsEnumerator.Move
              > > Next()\r\n at System.DirectoryServices.DirectorySearcher.FindOne()
              > > \r\n at ActiveDirectoryUtilities.ADUtil.GetUserInfo(String
              > > username) in c:\\Tarak\\Projects\\App_Code\\ADUtil.cs:line 207
              > >
              > > ----------------------------------------------------
              > >
              > > Thanks & Regards,
              > > Tarak.
              > >
              > >
              > > --- In ADSIANDDirectoryServices@yahoogroups.com<ADSIANDDirectoryServices%40yahoogroups.com>,
              > "Joe Kaplan"
              > > <joe@> wrote:
              > > >
              > > > Can you show the full stack trace of the error? Also, what is the
              > > value you
              > > > are using for the LDAP path?
              > > >
              > > > Joe K.
              > > >
              > > > ----- Original Message -----
              > > > From: "tarakvbhatt" <tarak.bhatt@>
              > > > To: <ADSIANDDirectoryServices@yahoogroups.com<ADSIANDDirectoryServices%40yahoogroups.com>
              > >
              > > > Sent: Wednesday, January 31, 2007 12:10 AM
              > > > Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher
              > > FindOne()
              > > > Method
              > > >
              > > >
              > > >
              > > > Hello Joe,
              > > >
              > > > Here is the code :
              > > > ----------------------------------------------------------
              > > > DirectoryEntry de = new DirectoryEntry(usersLdapPath, adLoginName,
              > > > adLoginPassword);
              > > >
              > > > DirectorySearcher ds = new DirectorySearcher(de);
              > > >
              > > > ds.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))
              > > > (objectCategory=user)(sAMAccountName=" + username + "))";
              > > >
              > > > ds.SearchScope = SearchScope.Subtree;
              > > >
              > > > ds.PropertiesToLoad.Add("cn");
              > > >
              > > > SearchResult r = ds.FindOne();
              > > >
              > > > ----------------------------------------------------------
              > > >
              > > > I am getting error in last sentence.
              > > > ( i.e. at ---> SearchResult r = ds.FindOne(); )
              > > >
              > > > It works well when I run the application from my developing
              > machine
              > > > (where OS is Windows XP).
              > > >
              > > > It only gives RANDOM problem of "Object reference not set to an
              > > > instance of an object" when I run the application from the server
              > > > (where OS is Windows Server 2003).
              > > >
              > > > Thanks for your support.
              > > >
              > > > Regards,
              > > > Tarak.
              > > >
              > >
              >
              >
              >


              [Non-text portions of this message have been removed]
            • tarakvbhatt
              Hello Ryan, nothing is doing on the machine at the same time for Active directory settings. Thanks & Regards, Tarak. ... same ... using? I ... 40hotmail.com
              Message 6 of 11 , Feb 7, 2007
              • 0 Attachment
                Hello Ryan,

                nothing is doing on the machine at the same time for
                Active directory settings.

                Thanks & Regards,
                Tarak.


                --- In ADSIANDDirectoryServices@yahoogroups.com, "Ryan Dunn"
                <dunnry@...> wrote:
                >
                > Are you or another process doing something on the machine at the
                same
                > time... like deleting users with the UI?
                >
                > On 2/2/07, Joe Kaplan <joe@...> wrote:
                > >
                > > Can you also show what the LDAP path looks like that you are
                using? I
                > > don't
                > > need your credentials, just a path example.
                > >
                > > Joe K.
                > >
                > > ----- Original Message -----
                > > From: "tarakvbhatt" <tarakvbhatt2003@...<tarakvbhatt2003%
                40hotmail.com>
                > > >
                > > To:
                <ADSIANDDirectoryServices@yahoogroups.com<ADSIANDDirectoryServices%
                40yahoogroups.com>
                > > >
                > > Sent: Friday, February 02, 2007 7:17 AM
                > > Subject: [ADSI-DirSrv] Re: Object Reference with DirectorySearcher
                > > FindOne()
                > > Method
                > >
                > > Hello Joe,
                > >
                > > Here is the code :
                > > ----------------------------------------------------------
                > >
                > > public void GetUserInfo(string username)
                > > {
                > >
                > > DirectoryEntry de = new DirectoryEntry(usersLdapPath, adLoginName,
                > > adLoginPassword);
                > > DirectorySearcher ds = new DirectorySearcher(de);
                > >
                > > try
                > > {
                > > ds.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))
                > > (objectCategory=user)(sAMAccountName=" + username + "))";
                > >
                > > ds.SearchScope = SearchScope.Subtree;
                > >
                > > ds.PropertiesToLoad.Add("cn");
                > >
                > > SearchResult r = ds.FindOne();
                > >
                > > ----------------------------------------------------------
                > >
                > > The last sentence gives the error.
                > > But please keep in mind that the error is RANDOM.
                > > i.e. it never occurs from my development machine.
                > > But RANDOMly it comes on WIN2003 Server machine.
                > >
                > > Thanks & Regards,
                > >
                > > Tarak.
                > >
                > > --- In
                ADSIANDDirectoryServices@yahoogroups.com<ADSIANDDirectoryServices%
                40yahoogroups.com>,
                > > "Joe Kaplan"
                > > <joe@> wrote:
                > > >
                > > > That's definitely not a good thing. There is something wrong in
                > > the guts of
                > > > the SearchResultCollection that isn't working correctly. I have
                no
                > > idea
                > > > what's wrong, but it may be necessary to report this to
                Microsoft
                > > to get a
                > > > diagnosis.
                > > >
                > > > If you could reprint the complete code sample that demonstrates
                the
                > > problem
                > > > here, I could try to replicate it myself.
                > > >
                > > > Out of curiosity, do you get different results if you change the
                > > filter?
                > > >
                > > > Joe K.
                > > >
                > > > ----- Original Message -----
                > > > From: "tarakvbhatt" <tarak.bhatt@>
                > > > To:
                <ADSIANDDirectoryServices@yahoogroups.com<ADSIANDDirectoryServices%
                40yahoogroups.com>
                > > >
                > > > Sent: Thursday, February 01, 2007 3:34 AM
                > > > Subject: [ADSI-DirSrv] Re: Object Reference with
                DirectorySearcher
                > > FindOne()
                > > > Method
                > > >
                > > >
                > > >
                > > > Hello Joe,
                > > >
                > > > Here is the stack trace of the error :
                > > >
                > > > ---------------------------------------------------
                > > > at
                > > >
                > >
                System.DirectoryServices.SearchResultCollection.ResultsEnumerator.Move
                > > > Next()\r\n at System.DirectoryServices.DirectorySearcher.FindOne
                ()
                > > > \r\n at ActiveDirectoryUtilities.ADUtil.GetUserInfo(String
                > > > username) in c:\\Tarak\\Projects\\App_Code\\ADUtil.cs:line 207
                > > >
                > > > ----------------------------------------------------
                > > >
                > > > Thanks & Regards,
                > > > Tarak.
                > > >
                > > >
                > > > --- In
                ADSIANDDirectoryServices@yahoogroups.com<ADSIANDDirectoryServices%
                40yahoogroups.com>,
                > > "Joe Kaplan"
                > > > <joe@> wrote:
                > > > >
                > > > > Can you show the full stack trace of the error? Also, what is
                the
                > > > value you
                > > > > are using for the LDAP path?
                > > > >
                > > > > Joe K.
                > > > >
                > > > > ----- Original Message -----
                > > > > From: "tarakvbhatt" <tarak.bhatt@>
                > > > > To:
                <ADSIANDDirectoryServices@yahoogroups.com<ADSIANDDirectoryServices%
                40yahoogroups.com>
                > > >
                > > > > Sent: Wednesday, January 31, 2007 12:10 AM
                > > > > Subject: [ADSI-DirSrv] Re: Object Reference with
                DirectorySearcher
                > > > FindOne()
                > > > > Method
                > > > >
                > > > >
                > > > >
                > > > > Hello Joe,
                > > > >
                > > > > Here is the code :
                > > > > ----------------------------------------------------------
                > > > > DirectoryEntry de = new DirectoryEntry(usersLdapPath,
                adLoginName,
                > > > > adLoginPassword);
                > > > >
                > > > > DirectorySearcher ds = new DirectorySearcher(de);
                > > > >
                > > > > ds.Filter = "(&(!
                (userAccountControl:1.2.840.113556.1.4.803:=2))
                > > > > (objectCategory=user)(sAMAccountName=" + username + "))";
                > > > >
                > > > > ds.SearchScope = SearchScope.Subtree;
                > > > >
                > > > > ds.PropertiesToLoad.Add("cn");
                > > > >
                > > > > SearchResult r = ds.FindOne();
                > > > >
                > > > > ----------------------------------------------------------
                > > > >
                > > > > I am getting error in last sentence.
                > > > > ( i.e. at ---> SearchResult r = ds.FindOne(); )
                > > > >
                > > > > It works well when I run the application from my developing
                > > machine
                > > > > (where OS is Windows XP).
                > > > >
                > > > > It only gives RANDOM problem of "Object reference not set to
                an
                > > > > instance of an object" when I run the application from the
                server
                > > > > (where OS is Windows Server 2003).
                > > > >
                > > > > Thanks for your support.
                > > > >
                > > > > Regards,
                > > > > Tarak.
                > > > >
                > > >
                > >
                > >
                > >
                >
                >
                > [Non-text portions of this message have been removed]
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.