Monday, October 29, 2007

AJAXPro here are some good examples...

For AjaxPro you can refer these code samples. And you can always get the AjaxPro download from any other site.

AjaxPro Code samples


MarkViky
@yahoo.com

Possible solution for : Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral,

I was browsing for a solution for the error thrown by the MOSS when you are using a webpart which uses connection to database...

"Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

a possible solution is like this :

This is due to SharePoint Portal Server and Windows SharePoint Services implementation of .NET Code Access Security (CAS). A solution that addresses the aforementioned error is cited below:

* Locate and open the wss_minimaltrust.config file (NOTE: If you've gone with the default SharePoint or WSS install, this file is located at :\Program Files\Common Files\Microsoft Shared\Server Extensions\60\Config)

* Add the following element to the SecurityClasses section of this config file:
< name="SqlClientPermission" description="System.Data.SqlClient.SqlClientPermission, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

* In the PermissionSet section of this configuration file, add the following:
< class="SqlClientPermission" version="1" unrestricted="true">


If you still run into the error, try adding these settings to the wss_mediumtrust.config file.

------
MarkViky
@yahoo.com

Saturday, October 27, 2007

Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions

Here is the download link from Microsoft for Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions.

These project templates will help in creating webparts in VS 2005

Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions

-MarkViky

Tuesday, August 28, 2007

Connecting to Active Directory - AD - using c#

Hi all, This is one of the most important and basic things a developer has to do in his life. Here I will show how to connect to the AD and get some basic information required.

I also have covered fetching manager's information in this topic, I faced problem while working with this. When you search AD with UserID, it returns a path to the manager's information. We have to use the path and search the AD again to get manager's mailid and other information...


public string GetManagerMailID(string UserName)
{
try
{
Hashtable hsEmpData;
string sManagersMailID = "";

hsEmpData = SearchLDAP(UserName);
foreach (DictionaryEntry deSearchDataKey in hsEmpData)
{
if (deSearchDataKey.Key.ToString() == "manager")
{
sManagersMailID = getManagersID(deSearchDataKey.Value.ToString());
break;
}
}
return sManagersMailID;
}
catch (Exception ex)
{
throw ex;
}
}




private static Hashtable SearchLDAP(string userID)
{
//Pass a connecetion string of sorts to the DirectoryEntry,
//Here replace ABC with domain name...
DirectoryEntry entry = new DirectoryEntry("LDAP://DC=ABC,DC=com");
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = "(&(objectClass=user)(anr="+ userID +"))";

mySearcher.PropertiesToLoad.Add("givenname"); // will give you first name
mySearcher.PropertiesToLoad.Add("sn"); // will give you last name
mySearcher.PropertiesToLoad.Add("mail"); // for mail id
mySearcher.PropertiesToLoad.Add("manager"); // for manager's information

Hashtable associateDetailsTable = new Hashtable();
ResultPropertyValueCollection resultCollection;

//search the AD depending on userID
SearchResult searchResult = mySearcher.FindOne();

//Add the details to the hashtable...
associateDetailsTable.Add("AssociateID", userID);
if(searchResult != null)
{
resultCollection = searchResult.Properties["givenname"];
foreach(object result in resultCollection)
{
associateDetailsTable.Add("FirstName", result.ToString());
break;
}
resultCollection = searchResult.Properties["sn"];
foreach(object result in resultCollection)
{
associateDetailsTable.Add("LastName", result.ToString());
break;
}
resultCollection = searchResult.Properties["mail"];
foreach(object result in resultCollection)
{
associateDetailsTable.Add("Mail", result.ToString());
break;
}
resultCollection = searchResult.Properties["manager"];
foreach (object result in resultCollection)
{
associateDetailsTable.Add("manager", result.ToString());
break;
}
}
return associateDetailsTable;
}




private string getManagersID(string managersString)
{
DirectoryEntry entry = new DirectoryEntry("LDAP://" + managersString);
DirectorySearcher mySearcher = new DirectorySearcher(entry);
//mySearcher.Filter = "(&(objectClass=user)(anr=" + userID + "))";

string sMailID="";

mySearcher.PropertiesToLoad.Add("givenname");
mySearcher.PropertiesToLoad.Add("sn");
mySearcher.PropertiesToLoad.Add("mail");

ResultPropertyValueCollection resultCollection;
SearchResult searchResult = mySearcher.FindOne();

if (searchResult != null)
{
resultCollection = searchResult.Properties["mail"];
foreach (object result in resultCollection)
{
sMailID = result.ToString();
break;
}
}
return sMailID;

}


- Vighnesh Bendre

Hope this post helps atleast one person.
For any doubts contact me at vikram.bendre@gmail.com

Tuesday, July 3, 2007

Everything that I want to say!!!

Yes, thats what I chose to be the title of my blog. I am not sure how much sense it makes, but it stuck to my mind while entering the title. Myself Vighnesh Bendre, working as Programmer Analyst in a multinational consulting firm. I am located in Bangalore, India. I have been banging my head in software consulting industry for over 6 years now, and I am successful in doing so :) .

Hope I will keep this blog alive. You can reach me at vikram.bendre@gmail.com

Cheers,
Vighnesh Bendre,