0x80040220 SecLib::CrmCheckPrivilege failed. Returned hr = -2147220960 on UserId: dd80d8b7-6700-dd11-9838-001185e68627 and PrivilegeId: 0b609bc5-afb0-4576-8db0-7ad715375833 Platform


Hi,

We upgraded from CRM 3 to CRM 4, and certain users got this error while trying to access the CRM.

We realized that the users receiving this error had our own custom security role assigned to them. i.e System Primer.

When we assigned them any of the existing default security role there was no problem in accessing the CRM.

So the way we resolved was to assign a default security role and our own custom role to the user, so that he could access the system for the first time without any issues and

after the user has accessed it once than we removed the default security role.

This approach worked for us!!!!

Or another thing that worked was if we are assigning any custom role to users, we gave the write permission for user settings in that custom role.

the kb article for this error are

http://support.microsoft.com/kb/953962/en-us

http://support.microsoft.com/kb/952279/en-us

Bye

Consuming an Asp.NET web service using SOAP protocol from JavaScript


There are many ways we can consume a web service
The three common protocols for accessing a .NET web service are
HTTP GET, HTTP POST and SOAP.
The trasport protocol used for them is HTTP. However a web sercie can work on any other internet protocol like SMTP, FTP, Jabber, and TCP.

For HTTP GET and HTTP POST method you can refer to these posts
https://nishantrana.wordpress.com/2007/10/22/calling-aspnet-web-service-from-javascript-ajax-passing-parameter/
https://nishantrana.wordpress.com/2007/10/22/calling-aspnet-web-service-from-javascript-ajax-passing-parameter-post/
The proxy class generated by Visual studio for us using the wsdl itself uses the SOAP.
Let’s take an example of calling the simple web service using SOAP through java script.
Say this is our sample web service

[WebService(Namespace = “http://myNamespace/”)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld(String name) {
return “Hello “+name;
}

}

The javascript code that we can use to call this web service using SOAP request would be this
<script type=”text/javascript”>
var xmlHttp;
function SoapCall()
{
// creatng the xmlHttp object
xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);
// Calling the web service using post and true means asynchronous call
xmlHttp.open(“post”, “http://localhost/WebSite/WebSite4/Service.asmx&#8221;, true);
// Setting the request header to let the web service identify the soap request we would be sending
xmlHttp.setRequestHeader(“Content-Type”,”text/xml; charset=utf-8″);
// http://myNamespace/HelloWorld – name of the webmethod
//[WebService(Namespace = “http://myNamespace/&#8221;)] which we had applied to our web service class
xmlHttp.setRequestHeader(“SOAPAction”,”http://myNamespace/HelloWorld&#8221;);
xmlHttp.onreadystatechange=doUpdate;
// setting the soap request body
var soapRequest=”<?xml version=’1.0′ encoding=’utf-8′?>” +
“<soap:Envelope xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance'”+
” xmlns:xsd=’http://www.w3.org/2001/XMLSchema&#8217; xmlns:soap=’http://schemas.xmlsoap.org/soap/envelope/’>”+
“<soap:Body>”+
“<HelloWorld xmlns=’http://myNamespace/’>”+
“<name>Nishant Rana</name> “+
“</HelloWorld>”+
” </soap:Body>”+
“</soap:Envelope>”;


xmlHttp.send(soapRequest);
return false;


}

function doUpdate()
{
debugger;
if(xmlHttp.readyState==4)
{
var responseXMLResult=xmlHttp.responseXML;
var result = responseXMLResult.lastChild.nodeTypedValue;
alert(result);
}
}
</script>

We will receive the following Soap Response
<?xml version=”1.0″ encoding=”utf-8″?>
<soap:Envelope xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema”&gt;
<soap:Body>
<HelloWorldResponse xmlns=”http://myNamespace/”&gt;
<HelloWorldResult>Hello Nishant Rana</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>

We can create our SOAP request by making use of the test page of our Web Service which we can open in IE.

Or else we can use Fiddler tool. (http://www.fiddlertool.com/fiddler/)

Bye..

0x80041102 -the entity with ObjectTypeCode = 4408 was not found in the Metadata Cache. Platform


I was receiving this error while I was using the tool JSExportFromCRM – a useful tool to backup javascripts for CRM.

While looking for the same the solution I found was this

First I ran this query

SELECT * from entity WHERE objecttypecode = 4408

It returned nothing

Than I ran the following query and it

select * from organizationuibase where ObjectTypeCode = 4408

returned a row.

So ran the following query (i.e deleted that entry)

Delete from organizationuibase where ObjectTypeCode = 4408

And than again run the tool and it worked properly!!

Bye

Unhandled Exception: Microsoft.SharePoint.SPException: The form submission cannot be processed because it exceeded the maximum length allowed by the Web administrator. Please resubmit the form with less data.


Hi,

When one of our users tried uploading a picture of size somewhere around 3 mb in the picture library, he received the above mentioned error. Initial solution that we found in the kb article was to increase the httpRuntime within our web site.

<httpRuntime maxRequestLength=”51200” />

maxRequestLength –

Optional Int32 attribute. Specifies the limit for the input stream buffering threshold, in KB. This limit can be used to prevent denial of service attacks that are caused, for example, by users posting large files to the server. The default is 4096 KB. If the threshold is exceeded, a ConfigurationErrorsException is thrown.

But as we can see it is already set to somewhere around 50mb so that shouldn’t be the problem.

Thankfully the solution for this was to open central administration site

Central Administration > Application Management > Web Application General Settings

There change the

Maximum Upload Size which was set to 2 mb to
desired value.

Bye

Url Behaviour – Asp.NET web service


When adding a webreference to a webservice in visual studio we can set the Url Behaviour property inside visual studio.

In visual studio 2003 by default it is set to static and in visual studio 2005 it is set default to dynamic.

Static means the url is set in the code within the generated proxy class Reference.cs.

Normally this file doesn’t show up in visual studio. Using Show All Files option in visual studio displays this file.

This is what would be there in generated proxy class for Url Behaviour Static

public CrmService() {

this.Url = http://d-3324:5555/mscrmservices/2006/crmservice.asmx&#8221;;

And in case of Dynamic we will find a corresponding entry for the url in our application config file.

<applicationSettings>

<WindowsFormsApplication1.Properties.Settings>

<setting name=WindowsFormsApplication1_CrmSdk_CrmService serializeAs=String>

<value>http://d-3324:5555/mscrmservices/2006/crmservice.asmx</value>

</setting>

</WindowsFormsApplication1.Properties.Settings>

</applicationSettings>

And inside our proxy class

public CrmService() {

this.Url = global::WindowsFormsApplication1.Properties.Settings.Default.WindowsFormsApplication1_CrmSdk_CrmService;

Bye

Updating value in CRM entity in Callout written for Update event


 

Well we had a requriement in our case where we wanted to update a particular attribute value in our Crm’s opportunity entity in our update callout.

While looking for the same I came to know that if we are updating any attribute’s value in the entity against which we have attached our update callout, we will be lost in infinite loop.

Only way to do this is in the PreUpdate and there is a sample code for the same in sdk as well.(Unsupported)

public override PreCalloutReturnValue PreUpdate(CalloutUserContext userContext,CalloutEntityContext entityContext, ref string entityXml,ref string errorMessage)

Here we can see that the entityXml is passed to us as a reference. So any modification made to the entityXml would reflect back in that entity’s form as well.

Suppose this is the entityXml which we receive in our PreUpdate event

<?xml version=1.0 encoding=utf-16?>

<BusinessEntity xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema xsi:type=DynamicEntity Name=opportunity xmlns=http://schemas.microsoft.com/crm/2006/WebServices>

<Properties>

<Property xsi:type=KeyProperty Name=opportunityid>

<Value>57330ec3-6f5d-dd11-acd2-00164145e126</Value>

</Property>

<Property xsi:type=CrmFloatProperty Name=new_estimatedvalue>

<Value>1</Value>

</Property>

<Property xsi:type=CrmMoneyProperty Name=estimatedvalue>

<Value>77.5</Value>

</Property>

</Properties>

</BusinessEntity>

Now after running this code in our preUpdate event handler we can add a new property tag itself, which would be refering to the attribute we would like to update

// creating an xmlDocument

XmlDocument entityDoc = new XmlDocument();

// loading the entityXml in it

entityDoc.LoadXml(entityXml);

// the attribute which we would like to update

XmlElement totatForecastedValue = null;

// get the list of properties

XmlNodeList propertyList = entityDoc.GetElementsByTagName(“Property”);

XmlElement properties = (XmlElement)entityDoc.GetElementsByTagName(“Properties”)[0];

// creating an element with property tag

XmlElement totalForecastedElement = entityDoc.CreateElement(“Property”);

// creating an attribute type for the property tag

XmlAttribute typeAttrib = entityDoc.CreateAttribute(“type”);

totalForecastedElement.SetAttribute(“type”, http://www.w3.org/2001/XMLSchema-instance&#8221;, CrmFloatProperty”);

totalForecastedElement.SetAttribute(“Name”, “new_totalbilling”);

totatForecastedValue = entityDoc.CreateElement(“Value”);

// setting the value for the attribute

totatForecastedValue.InnerText = “10”;

totalForecastedElement.AppendChild(totatForecastedValue);

properties.AppendChild(totalForecastedElement);

 

//saving the output

StringWriter output = new StringWriter();

entityDoc.Save(output);

 

// assigning the same output to the entityXml

entityXml = output.ToString();

 

// Remove extra XML that will confuse CRM.

entityXml = entityXml.Replace(“xmlns=\”\””, “”);

entityXml = entityXml.Replace(“<?xml version=\”1.0\” encoding=\”utf-16\”?>”, “”);

The entityXml gets modified with the above code in this manner

<BusinessEntity xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema xsi:type=DynamicEntity Name=opportunity xmlns=http://schemas.microsoft.com/crm/2006/WebServices>

<Properties>

<Property xsi:type=KeyProperty Name=opportunityid>

<Value>57330ec3-6f5d-dd11-acd2-00164145e126</Value>

</Property>

<Property xsi:type=CrmFloatProperty Name=new_estimatedvalue>

<Value>1</Value>

</Property>

<Property xsi:type=CrmMoneyProperty Name=estimatedvalue>

<Value>77.5</Value>

</Property>

<Property xsi:type=CrmFloatProperty Name=new_totalbilling >

<Value>10</Value>

</Property>

</Properties>

</BusinessEntity>

 

And this way our entity gets updated as well.

And the same code in CRM 3.0 callout  works properly in case of upgrading the CRM 3.0 server to CRM 4.0 .

 

Bye..

 

 

Nishant Rana's Weblog

Everything related to Microsoft .NET Technology

Skip to content ↓