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

works as localhost but not in IIS

Expand Messages
  • pio_richard
    Hi, Here is the code that i am using to authenticate a user. this works fine when i work with localhost(asp.net 2005 inbuilt iis). but when i deployed the page
    Message 1 of 3 , Oct 19, 2008
    • 0 Attachment
      Hi, Here is the code that i am using to authenticate a user. this
      works fine when i work with localhost(asp.net 2005 inbuilt iis). but
      when i deployed the page to a IIS webserver then it throws "An
      operations error occurred".

      Here is my code:

      bool IsExistInAD(string loginName)
      {
      string userName = loginName;
      bool retVal = false;

      try
      {
      string strLDAP = "LDAP://cn=xxxx,ou=xxxDistribution Lists,ou=ZZ
      DXB,ou=domainname,dc=SD01,dc=domainname,dc=st";

      DirectoryEntry objDirEntry = new DirectoryEntry
      (strLDAP, "domainname\\username", "password",
      AuthenticationTypes.Secure);
      //objDirEntry.Path =
      Response.Write(objDirEntry.Username.ToString());
      DirectorySearcher search = new DirectorySearcher
      (objDirEntry);

      search.Filter = String.Format("(SAMAccountName={0})",
      userName);
      search.PropertiesToLoad.Add("cn");

      SearchResult result = search.FindOne();

      if (result == null)
      {
      retVal= false;
      }
      else
      {
      retVal= true;
      }
      }
      catch (Exception ex)
      {
      Response.Write("IsExistInAD - " + ex.Message.ToString()
      + "<br>");
      Response.Write("IsExistInAD - " + ex.Source.ToString()
      + "<br>");
      //Response.Write(userName);
      }
      Response.Write(retVal.ToString());
      return retVal;
      }


      ALWAYS IT RETURNS FALSE...
    • wei huang
      that is probably you are running your code in localhost as admin right, but if a regular user access iis, they dont have it, then it will return error, what
      Message 2 of 3 , Oct 27, 2008
      • 0 Attachment
        that is probably you are running your code in localhost as admin right, but if a regular user access iis, they dont have it, then it will return error, what you might do is put your code as component on iis, that should work for you

        --- On Sun, 10/19/08, pio_richard <pio_richard@...> wrote:

        From: pio_richard <pio_richard@...>
        Subject: [ADSI-DirSrv] works as localhost but not in IIS
        To: ADSIANDDirectoryServices@yahoogroups.com
        Date: Sunday, October 19, 2008, 9:26 AM






        Hi, Here is the code that i am using to authenticate a user. this
        works fine when i work with localhost(asp. net 2005 inbuilt iis). but
        when i deployed the page to a IIS webserver then it throws "An
        operations error occurred".

        Here is my code:

        bool IsExistInAD( string loginName)
        {
        string userName = loginName;
        bool retVal = false;

        try
        {
        string strLDAP = "LDAP://cn=xxxx, ou=xxxDistributi on Lists,ou=ZZ
        DXB,ou=domainname, dc=SD01,dc= domainname, dc=st";

        DirectoryEntry objDirEntry = new DirectoryEntry
        (strLDAP, "domainname\ \username" , "password",
        AuthenticationTypes .Secure);
        //objDirEntry. Path =
        Response.Write( objDirEntry. Username. ToString( ));
        DirectorySearcher search = new DirectorySearcher
        (objDirEntry) ;

        search.Filter = String.Format( "(SAMAccountName ={0})",
        userName);
        search.PropertiesTo Load.Add( "cn");

        SearchResult result = search.FindOne( );

        if (result == null)
        {
        retVal= false;
        }
        else
        {
        retVal= true;
        }
        }
        catch (Exception ex)
        {
        Response.Write( "IsExistInAD - " + ex.Message.ToString ()
        + "<br>");
        Response.Write( "IsExistInAD - " + ex.Source.ToString( )
        + "<br>");
        //Response.Write( userName) ;
        }
        Response.Write( retVal.ToString( ));
        return retVal;
        }

        ALWAYS IT RETURNS FALSE...


















        [Non-text portions of this message have been removed]
      • Andrzej Raczynski
        Or perhaps look into the account impersonate (account with admin rights) setting to put into your web.config. From: ADSIANDDirectoryServices@yahoogroups.com
        Message 3 of 3 , Oct 27, 2008
        • 0 Attachment
          Or perhaps look into the 'account impersonate' (account with admin rights)
          setting to put into your web.config.



          From: ADSIANDDirectoryServices@yahoogroups.com
          [mailto:ADSIANDDirectoryServices@yahoogroups.com] On Behalf Of wei huang
          Sent: Monday, October 27, 2008 8:36 AM
          To: ADSIANDDirectoryServices@yahoogroups.com
          Subject: Re: [ADSI-DirSrv] works as localhost but not in IIS



          that is probably you are running your code in localhost as admin right, but
          if a regular user access iis, they dont have it, then it will return error,
          what you might do is put your code as component on iis, that should work for
          you

          --- On Sun, 10/19/08, pio_richard <pio_richard@...
          <mailto:pio_richard%40hotmail.com> > wrote:

          From: pio_richard <pio_richard@...
          <mailto:pio_richard%40hotmail.com> >
          Subject: [ADSI-DirSrv] works as localhost but not in IIS
          To: ADSIANDDirectoryServices@yahoogroups.com
          <mailto:ADSIANDDirectoryServices%40yahoogroups.com>
          Date: Sunday, October 19, 2008, 9:26 AM

          Hi, Here is the code that i am using to authenticate a user. this
          works fine when i work with localhost(asp. net 2005 inbuilt iis). but
          when i deployed the page to a IIS webserver then it throws "An
          operations error occurred".

          Here is my code:

          bool IsExistInAD( string loginName)
          {
          string userName = loginName;
          bool retVal = false;

          try
          {
          string strLDAP = "LDAP://cn=xxxx, ou=xxxDistributi on Lists,ou=ZZ
          DXB,ou=domainname, dc=SD01,dc= domainname, dc=st";

          DirectoryEntry objDirEntry = new DirectoryEntry
          (strLDAP, "domainname\ \username" , "password",
          AuthenticationTypes .Secure);
          //objDirEntry. Path =
          Response.Write( objDirEntry. Username. ToString( ));
          DirectorySearcher search = new DirectorySearcher
          (objDirEntry) ;

          search.Filter = String.Format( "(SAMAccountName ={0})",
          userName);
          search.PropertiesTo Load.Add( "cn");

          SearchResult result = search.FindOne( );

          if (result == null)
          {
          retVal= false;
          }
          else
          {
          retVal= true;
          }
          }
          catch (Exception ex)
          {
          Response.Write( "IsExistInAD - " + ex.Message.ToString ()
          + "<br>");
          Response.Write( "IsExistInAD - " + ex.Source.ToString( )
          + "<br>");
          //Response.Write( userName) ;
          }
          Response.Write( retVal.ToString( ));
          return retVal;
          }

          ALWAYS IT RETURNS FALSE...

          [Non-text portions of this message have been removed]





          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.