Same code works in web service, but not working when I call it from web page

Any idea about the following?
Error msg: The specified domain either does not exist or could not be contacted.
1. in the web service, I have such code working fine when I debug it:
<WebMethod()> _Public Function SetUserPassword(ByVal userid As String, ByVal oldpwd As String, ByVal newpwd As String) As StringTry     Dim searcher As New System.DirectoryServices.DirectorySearcher()     searcher.Filter = "(&(objectClass=user)(objectCategory=person)(sAMAccountName=" & userid & "))"     searcher.PropertiesToLoad.Add("adspath")     Dim Result As System.DirectoryServices.SearchResult = searcher.FindOne()     Dim test As New DirectoryServices.DirectoryEntry(Result.Path)    Try        test.Invoke("ChangePassword", New Object() {oldpwd, newpwd})        test.CommitChanges()     Catch err As Exception                  Return err.InnerException.Message      End Try Catch ex As Exception       Return ex.Message  End Try  Return "Success"End Function2. it generates error "The specified domain either does not exist or could not be contacted." when I run the following code in aspx web page

Protected Sub btnSetup_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSetup.Click

Dim ws As New websvc.Service

Dim strResult As String = ""


If txbNewPWD.Text = txbConfirmNewPWD.Text Then

strResult = ws.SetUserPassword(txbUserID.Text, txbOldPwd.Text, txbNewPWD.Text)


End If

Catch ex As Exception


End Try


End Sub

6/18/2008 6:17:36 PM 93655 articles. 6 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 9

I fixed the problem.

 1) in the web service: provide the server or domain in the binding string and supply some credentials from a service account

  • Code:     <WebMethod()> _    Public Function SetUserPassword(ByVal userid As String, ByVal oldpwd As String, ByVal newpwd As String) As String        Dim strReturn As String        Dim path As String = "LDAP://omni.local/OU=Lidia,OU=zOmniTests,DC=omni,DC=local"        Dim entry As DirectoryEntry = New DirectoryEntry(path)        Try            Dim searcher As New System.DirectoryServices.DirectorySearcher(entry)            searcher.Filter = "(&(objectClass=user)(objectCategory=person)(sAMAccountName=" & userid & "))"            searcher.PropertiesToLoad.Add("adspath")            Dim Result As System.DirectoryServices.SearchResult = searcher.FindOne()             Dim test As New DirectoryServices.DirectoryEntry(Result.Path)            Try                test.Invoke("ChangePassword", New Object() {oldpwd, newpwd})                test.CommitChanges()                strReturn = "Success"            Catch err As Exception                If Not err.InnerException Is Nothing Then                    strReturn = err.InnerException.Message                Else                    strReturn = err.Message                End If            End Try        Catch ex As Exception            strReturn = ex.Message        End Try        Return strReturn     End Function
  • Web.config: 
<identity impersonate ="true" userName ="XXX" password ="XXX"/>

<authentication mode="Windows" />

 2) In the web page: ·         Code:    Protected Sub btnSetup_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSetup.Click        Dim ws As New websvc.Service        Dim strResult As String = ""        Try            If txbNewPWD.Text = txbConfirmNewPWD.Text Then                strResult = ws.SetUserPassword(txbUserID.Text, txbOldPwd.Text, txbNewPWD.Text)            Else            End If        Catch ex As Exception            Response.Write(strResult)        End Try        Response.Write(strResult)    End Sub 
  • Web.config
<identity impersonate ="true" userName ="XXX" password ="XXX"/>

<authentication mode="Windows" />

Hope this will also help you out. Enjoy programming!!

6/19/2008 2:23:30 PM

Similar Artilces:

web web web
Name: bahadir Email: Product: Firefox 2 Beta 2 Summary: web web web Comments: web sayfası yapmak Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

Troubleshoot Web Service; Ajax AutoComplete events do not appear to not fire; Ajax web service appears to not work. .NET
Folks, I had the situation that Ajax AutoComplete events in the web service did not fire after I copied a project out of a folder, renamed it and moved it to a server. The fix was hard to find but easy to solve. I had some web service modules in an ASMX file that provided AutoComplete entries -- i.e., after the user keys in 2 or 3 characters, the list of possible entries with those leading characters is displayed for the user to select. To solve the problem, look at the web service's directive, not the code-behind or the ASMX designer.  Do a right-mouse-click...

difference of calling web services and calling web page
Dear all,  What is the difference of call a web services instead of calling a aspx page which is also programming can accept parameters and return results? Webservice -- Soap protocol Webapplication  -- HTTP protocol Webservices are of two Major types Xml & SOAP HttpWebServices Basic difference is in usage and implementation. We use a webservice inside a website. it is added as a reference or we can call it through HttpWebRequests and Response objects. Webpages are the components that have presentation and logic, while web services provide the service that we...

after installing web matrix VB.NET web page don't work
I just started with ASP.NET in VB.NET. I had developed a simple web page and it worked fine. Then I installed web matrix and started playing with it. When I go back to VB and try to run the program (that worked before) I get an error: "Unable to start debugging on the web server. Could not start ASP.NET or ATL server debugging." How do I get VB.NET to working again? I'm not sure why your existing Web application don't work after the installation of Web Matrix, as they can live without conflict in fact, did you try to look for an answer from the about the ...

Calling a Web Service from a Web Service
Hello,I was looking for some feedback on calling a web service from within a web service. I've heard that it's not good practice (or not possible). I have a scenario where I think it might make some sense.Within our infrastructure, we've created a web service that handles incoming updates on the statuses of all processes. This has proven to be a good thing since it allows applications to communicate across server to make status updates. It's also used by third party developers and applications to communicate with our infrastructure.Along these lines ... we are planning to create a new compon...

Microsoft AJAX Application Works On LocalHost But Not Web Host
I recently made some changes to a example site: The site functions correctly on my computer but when I upload it to a remotee server it does not.  I have tested it in both medium and full trust and it still does not work on a remote host. The URL of the page that I want to become the primary page is here:  The code for the web service calls and bridge is almost entirely based on the example here:  It works on my personal computer fi...

Can you return .net web controls in a .net page from a web service?
I've got a problem with a project. I've got to compile an entire .net page and return it as part of a Web Service for display. The problem I have is that I need to add WebControls and functionality to the page so that not only the html content and images are displayed (which I've managed) but that textboxes, labels, buttons and datasets can be displayed also. Essentially I need to make a call from one site for a page, populate the page and return it in a state as though it resided on the same server/webspace as the calling page. Code is currently built as follows into a string: strOpenHT...

Unable to call web service from web page
 I know this has probably been asked dozens of times before but as it's a fairly general, simple question I'm not sure what to search under.I have a very simple web service that I want to make a callback to (from an AJAX.NET ScriptManager). At this stage all it returns is the out-of-the-box Hello World string. The web service, DataService.asmx, is as follows:[WebService(Namespace = "")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][System.Web.Script.Services.ScriptService()]public class DataService : System.Web.Services.WebService{&nbs...

Web User Control not working on Web Page
I created a web user control to contain 3 grids and then used a span tag so that the window shows only one grid but can be vertically scrolled to show all three.  It works great on the control but when I drag the control onto a web page all 3 grids are displayed and the scroll bars are missing.  Does anyone have any suggestions for this or have run into this problem before.  Thanks........

Can my web page with a form submit to other web pages forms?
I was wondering if I created an aspx page that had a form on it that I could use the submit button to submit this form's contents to other web pages forms(servers accepting those form's data). I am thinking this would be a great way to update data on particular web pages without having to actually visit those similar web pages. Any ideas, examples would be much appreciated. Thanks in advance.  Yes you can.  It's called Cross Page Posting: might ...

my web service call works from one page, not from the other.
 have a user control that uses Atlas to call a web service.  I drop this control on a page in the root directory and it works with no problem.  I then add the control to another control, which is on another page and it will not work.  It does not seem to know what the webService is. My web service is in the same project and the ascx control and is named meterCommunication.asmx in a folder called webService. The control is a button ond onClick it callas a javascript function that has the following line for calling the web service: meterCommunication.sendMessage(meterID...

Is there a way to add MVC to an existing web-forms-based web site so that the old .aspx pages still work alongside MVC?
I have an existing web site that needs to continue working in its old fashion as I make updates to it. I want to add the MVC framework to the web site, and then, as time permits, I want to be able to convert the original web forms-based pages into MVC-style actions/urls/views/etc. All the while, having both styles of pages working at the same time, so that I could for example update one section of the web site to use MVC and leave the rest of the site still using the web form style. Is this possible? Is it just as easy as doing it, or is there some special configuration t...

All web pages hang on web server when one of the web pages calls a run away sql query
Hi: We have a Windows 2003 dedicated web server running the .NET Frameworks 1.0 and 2.0.  We have a SQL Server cluster running SQL Server 2000.  Unfortunately, we do not have a test environment.  I have 2 .NET web sites in production.  My coworker has a voting .NET web page using AJAX on the same server.  The coworker wrote a query that was not indexing properly and when the page fired the query...the cluster went to almost 100% utilization.  My two web pages would hang and show a blank white page on the default.aspx.  Neither of m...

Web resources about - Same code works in web service, but not working when I call it from web page -

United States Department of Health and Human Services - Wikipedia, the free encyclopedia
The United States Department of Health and Human Services ( HHS ) is a Cabinet department of the United States government with the goal of protecting ...

Canberra murder victim Andrew Carville farewelled at funeral service
North Canberra man's body was found&nbsp;in grassland&nbsp;more than two weeks after he went missing.&nbsp;

Ambulance service welcomes new paramedics amid emergency services overhaul
The ACT's ambulance service has welcomed nine new intensive care paramedics, including the last cohort to be qualified under the territory's ...

Yahoo’s new Video Guide app offers universal search across streaming services
... Guide” app for mobile devices that acts as one central location for users to find content from across a long list of competitive video services ...

Why the blockchain will propel a services revolution
Blockchain promises to reduce construction times, transform global payments, overhaul the logistics and legal industries and allow devices around ...

Apple: Banking License, Cloud Services, Enterprise, Sky’s the Limit, Says Citi
Citigroup ’s Jim Suva this morning reiterates a Buy rating on shares of Apple ( AAPL ), and a $145 price target, after concluding positively ...

- U.S. Fish and Wildlife Service starts species review for black-and-orange butterfly
A far-flying butterfly known to pass through Central Oregon may land on the Endangered Species list. The U.S. Fish and Wildlife Service last ...

Why Apple’s cable-killing TV subscription service fell apart
A TV subscription service was supposed to be the flagship feature on Apple's fourth-gen Apple TV. Rumored to be in the works for quite some time, ...

Londoners took more than 45,000 uberPOOL journeys in the first week of the service going live
More than 45,000 UberPOOL journeys were completed in London within a week of the service going live in the city, Uber said in a press release. ...

Apple Watch 2 rumors and Apple's live TV service is put 'on hold'
If Apple's live TV service doesn't launch in 2016 it will be a major fail. We'll be as nice as possible when we talk about that iPhone Smart ...

Resources last updated: 12/13/2015 5:34:01 PM