Code (27)

25-09-2019 Programmatic Logic - Munafiq, Amanat may Khayanat - Hypocrite, Breach of Trust
06-10-2018 From wireframe to HTML, Design to Code - AI Power Sample
08-11-2012 Recursive Query Parent Child Concatenation
25-04-2012 Change or remove filter / filter content from Sharepoint list / library view columns
20-04-2011 Sigin as different user in asp.net using Windows authentication
26-01-2011 Powershell CmdLets
30-05-2010 Update Statistics - Query to find tables and index number of statistics being old
15-03-2010 Passing encrypted data between JavaScript and C#
12-02-2010 Sharepoint - SPWeb.Groups Vs SPWeb.SiteGroups
28-01-2010 Accessing JD Edwards Data on iSeries or AS/400 from a ASP.NET / SQL Encoding / Error problem
28-01-2010 Controls not functional after Export to Excel or Export to PDF of Telerik in Sharepoint Application page
05-10-2009 ASP.NET Cannot open log for source {0}. You may not have write access. - Access is denied
28-08-2009 CRM - The SELECT permission was denied on the object 'BuildVersion', database 'MicrosoftCRM_MSCRM', schema 'dbo'
22-08-2009 CRM - Retrieve Cultures information from CRM into your Custom Web Application
21-08-2009 CRM - Globalization / Localization in Custom Web Application
19-08-2009 CRM - Do you want to save this file? Blank.aspx?
18-08-2009 CRM Exception - Microsoft.Crm Application.Platform.Report. InternalCreate(String xml)
18-08-2009 CRM Exception - Microsoft.Crm.Reporting SRSReport.convertDataSource()
24-06-2009 Oracle SQL Developer - Unable to create an instance of the Java Virtual Machine
27-01-2009 Detecting Idle time or Inactivity in Windows Forms
23-01-2009 PasswordChar and Set focus on page load for ToolStripTextBox
21-01-2009 Capture Form Close Event
21-01-2009 Richtextbox or multiline textbox and AcceptButton to handle Enter or Tab key press
21-01-2009 Key Combination shortcuts in C# Windows Form
01-01-2009 Convert string to hexadecimal and hexadecimal to string
31-12-2008 Implementing Transaction in Stored Procedure
31-12-2008 Implementing Transaction in .NET
Mon 15 Mar 2010

This post posted by Vladimir Kuzin on 15th Oct 2009. For Quick reference posted here.

Few weeks ago I was working on project which required data to be encrypted using C# and then decrypted using JavaScript. In my case JavaScript was an internal scripting language, which wasn’t exposed to public so I didn’t have to worry about people accessing encryption keys. Project objective was to encode parameter in URL preventing users from substituting it with sequential numbers.

Research:

At first I’ve decided to use symmetric algorithm and looked online for available JavaScript libraries. In my search I’ve found few AES libraries to choose form. After further analysis it was determined that most people had good luck with slowAES, and I’ve attempted to implement it. After spending some time I was unable to decrypt any data encoded with RijndaelManaged class in C#. Since I had to find solution fast I’ve moved on.

Next I’ve decided to try asymmetric encryption algorithm, and after quick research I went with RSA. After downloading most popular RSA library for JavaScript I’ve run into several issues with its implementation. I was able to use C# to decode everything what was encoded in JavaScript, but it didn’t work when data was flowing in opposite direction. After looking into the issue it appeared that JavaScript library was missing padding, however using patched versionof the library didn’t help.

Solution:

Due to lack of time I’ve decided to use simpler encryption algorithm and went with RC4. After downloading RC4 JavaScriptlibrary I’ve got it to work within minutes. Since there is no such thing as RC4 cryptographic provider in the Security.Cryptography namespace I had to use open source RC4 library.

After encrypting data I’ve also converted it to hex (base 16) in the same way as it was done on the JavaScript RC4 demo page.

Encrypting URL parameter with RC4 didn’t completely meet the objective, since it still was possible for users to use sequential numbers. Take a look at example of encrypted data below:

Input Output
10001 49845da1c0
10002  49845da1c3

Notice that only last digit of the encrypted data has changed, therefore substituting it with sequential numbers will cause an issue. To solve this I’ve added random prefix and suffix blocks to data before encrypting. Prefix and suffix blocks consisted from random letters and were anywhere between 10 and 25 characters in length. Now data looked like this:

Input:
JQNLAZXAHHSHMIL;10001;GURUOTCBBNHDCZUNFXIGKP
Output:
32e523ddb00fbf2465002bc1b4251dd12876677d47d6a 6a3101a68517dfb6a86fa525139300d65225e365a38

Every time encrypted value is changing, since it’s generated from new random data. After transferring and decrypting this data on the JavaScript side I’ve spited string by semicolon to get the actual parameter value.

I am sure there are different and possibly better solutions somewhere out there, but this one worked for my client and was implemented within a small project budget.

This is post is from original Post @ vkuzin.com/post/Passing-encrypted-data-between-C-and-JavaScript.aspx

 

Tags: , ,
Comments (3)
Fri 12 Feb 2010

SPWeb has two sharepoint cross-site group collection, SPWeb.Groups and SPWeb.SiteGroups.

SPWeb.Groups returns collection of cross-site groups which has some permission on the site. So if you add group from a site without any permission on the site, then this group wont appear in SPWeb.Groups collection, but it will appear in SPWeb.SiteGroups collection.

You can not use SPWeb.Groups.Add method to add new cross-site group, you need to use SPWeb.SiteGroup.Add method for this purpose.

In addition to this SPWeb has a property AssociatedOwnerGroup, which will return the required SPGroup. You can iterate the SPGroup users to get the list of all owners of the site.

 foreach (SPUser user in web.AssociatedOwnerGroup.Users)
 {
      // .. list all the users                        
 }

 

Finding and adding group

SPGroup  group = GetSiteGroup(web, "groupName");
if (null == group)
{
 web.SiteGroups.Add("groupName", web.AssociatedOwnerGroup, null, "Test Group description");
}

 


private static SPGroup GetSiteGroup(SPWeb web, string name)
{
    foreach (SPGroup group in web.SiteGroups)
    {
 if (group.Name.ToLower() == name.ToLower())
 {
     return group;
 }
    }
 return null;
}

 

 

Tags: , ,
Comments here
Thu 28 Jan 2010

Accessing JD Edwards Data on iSeries or AS/400 from a ASP.NET

Facing problem, while retrieving field data from JD Edwards to SQL (SSRS Reporting), giving Error or Special unicode characters,
because, the returning data was a stream that needs to be converted into ASCII (ebcdic37String) using Cp037 Encoding.


public static String convertEBCDIC37ToUnicode(String ebcdic37String)
{
 String encoding = "Cp037";
 byte[] ebcdic;
 String converted = null;
 try
 {
  ebcdic = ebcdic37String.getBytes();
  converted = new String( ebcdic, encoding );
 }
 catch (Exception e)
 {
  //Handle it
 }
 return converted;
}

 

Comments here
Thu 28 Jan 2010

Few days before, I was having problem that after clicking on Export to pdf button / image, other controls of web part/user control stops working on the application page on WSS 3.0 environemnt that has RadGrid on it.

While the same thing was working on other asp.net application outside the sharepoint environment.

1st workaround (can be a solution)

The cause for this behavior is that there is a flag (named _spFormOnSubmitCalled) in SharePoint which prevents double form submition. This flag is set when the form is submitted and clear when the response is received.
However when exporting the response is redirected and the page is not updated, thus the flag is not cleared and page's postbacks are blocked.

In order to workaround this behavior you should manually clear the flag when exporting. This can be achieve, for example in export button's client click function similar to the following:

MyExportButton.OnClientClick = "_spFormOnSubmitCalled = false;"  

Above workaround will allow you to export multiple times, but all the other controls on the page were still not functional after the export.

2nd workaround (Not / Never recommended)

In your sharepoint master page, remove onsubmit attribute from your form tag

<form runat="server" onsubmit="return _spFormOnSubmitWrapper();"> 

and remove the onsubmit attribute.  This is what it looks like now:

<form runat="server"> 

3rd workaround (so far so good and implementable)

Add the following script to your webpart / custom control that need to have export and other controls functionals, rather then implementing the above workarounds
So here you go with the working solution.

<script type="text/javascript" language="javascript">

    //sharepoint postback to work after clicking on telerik export to pdf
    if (typeof (_spBodyOnLoadFunctionNames) != 'undefined' && _spBodyOnLoadFunctionNames != null) {
        _spBodyOnLoadFunctionNames.push("supressSubmitWraper");
    }

    function supressSubmitWraper() {
        _spSuppressFormOnSubmitWrapper = true;
    }
   
</script>

 

Hope this will helps.

 

Comments (23)
Mon 5 Oct 2009

Today I was getting following error while writing to Event Log on Windows 2008 Server (also applicable to windows 2003 server) using .NET

The resolution worked for me was appending (A;;0x3;;;AU) in CustomSD without quotes under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Eventlog\EventLogName in windows registry where AU is referring to "Authenticated Users". Because in W2K3, the security of Application Event Log is controlled by CustomSD.
After appending the value would be similier to

O:BAG:SYD:(D;;0xf0007;;;AN)(D;;0xf0007;;;BG)(A;;0x f0007;;;SY)(A;;0x7;;;BA)(A;;0x7;;;SO)(A;;0x3;;;IU)(A;;0x3;;;SU)(A;;0x3;;;S-1-5-3)(A;;0x3;;;AU)


If CustomSD doesnt exists, then create a string named CustomSD and set its value to O:BAG:SYD:(A;;0x3;;;AU)

 P.S. Be careful by taking proper backup of registry before doing any change to it.

 

 

Comments (1)
Fri 28 Aug 2009

Yesterday, after restoring CRM DB backup on other maching and importing Organization using Deployment Manager of CRM 4.0, I received this error.

The SELECT permission was denied on the object 'BuildVersion', database 'MicrosoftCRM_MSCRM', schema 'dbo'
or the variation
The SELECT permission was denied on the object 'SystemUser', database 'MicrosoftCRM_MSCRM', schema 'dbo'

If you have tried changing the owner of new database with admin login making it as dbowner but did not help then following may help solving this problem

Right click the affected object (table/view etc) in my case it was 'BuildVersion' and 'SystemUser' in SQL Server Management Studio,
click on properties
click on "Permissions" on left tab
click on "View schema permission" link on right tab
click on "Add" button,
click on "Browse" 
select "CRMReaderRole" of type Database role.
click ok,
click ok,
now you will be again in object properties.
Place check mark in "Grant" column against "Select" permission
click ok

Now check hope so it has been resolved.

================

To change the dbowner command is (If required)

use <CRMDatabaseThatYouNeedToChangeTheOwner>
exec sp_changedbowner 'DOMAIN\AdministratorMappedWithCrmAdmin'
go


===============

Comments (2)
Sat 22 Aug 2009


Following code will help to Retrieve Cultures information from CRM into your Custom Web Application

                     // Retrieve the Locale IDs from the server.
                    RetrieveProvisionedLanguagesRequest reqLang = new RetrieveProvisionedLanguagesRequest();
                    RetrieveProvisionedLanguagesResponse resLang = (RetrieveProvisionedLanguagesResponse)crmService.Execute(reqLang);

                    // Create a CultureInfo array that represents the available languages.
                    System.Globalization.CultureInfo[] cultures =
                        new System.Globalization.CultureInfo[resLang.RetrieveProvisionedLanguages.Length];

                    for (int i = 0; i < resLang.RetrieveProvisionedLanguages.Length; i++)
                    {
                        cultures[i] = System.Globalization.CultureInfo.GetCultureInfo(resLang.RetrieveProvisionedLanguages[i]);
                    }


If you are looking for Globalization / Localization in Custom Web Application, have a look at

http://faisal.azmza.com/post/2009/08/21/CRM-Globalization-Localization-in-Custom-Web-Application.aspx

 

 

 

Tags: ,
Comments here




Ads