开发者

Using a webservice with vbscript - "An operations error occurred."

I've been fiddling a bit with c# webservices and vbscript. Things work fine if I trigger the services manually through IE directly on the webserver, but when I try to run the same service from a vbscript it throws a "An operations error occurred." exception.

The service is pretty simple, all it does is create a computer object in Active Directory.

DirectoryEntry Container = new DirectoryEntry("LDAP://ldapgw/" + LDAPLocation); 
DirectoryEntries ComputerOU = Container.Children; 
DirectoryEntry ComputerObject = ComputerOU.Add("CN=" + ComputerName, "computer"); 
ComputerObject.InvokeSet("sAMAccountName", ComputerName); 
ComputerObject.InvokeSet("description", "Reserved"); 
ComputerObject.InvokeSet("userAccountControl", 4128); 
ComputerObject.CommitChanges(); 

It's triggered this way:

Set soap = CreateObject("Msxml2.XMLHTTP") 

soap "POST", URL, false, username, password 

soap.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
soap.setRequestHeader "SOAPAction", nsURL + service 

soap.send xml

I'm guessing this has something to do with permissions, but I can't figure out what. I'm using impersonation and if I output WindowsIdentity.GetCurrent() it seems to be running as t开发者_JS百科he correct user which has the needed rights in AD.

Does anyone know what I'm doing wrong?


try keeping your code inside this block

Using HostingEnvironment.Impersonate()
....you code....
End Using

This will impersonate the account from the apppool when authenticating with AD. If the app pool identity has the right access to AD, it will work the usual.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜