August 27, 2012

How to search Active directory for email and name of current NT user

You can search for your organisation's Active directory for particular user's email-id, first name, last name and many other vital information using LDAP.

what you need
1) LDAP Address
2) Any valid active directory credentials (e.g yours own)

No need to install any third party software etc.

Code snippet:-

var userWithoutDomainName = "skumar"

var entry = new DirectoryEntry("LDAP://DC=company, DC=com"/>, "username", "password");//username //is without domain
            var searcher = new DirectorySearcher{
                SearchRoot = entry,
                Filter = "(SAMAccountName=" +userWithoutDomainName + ")" };
            searcher.PropertiesToLoad.Add("Mail"); //email-id
            searcher.PropertiesToLoad.Add("givenName");//first name
            searcher.PropertiesToLoad.Add("st");
            searcher.PropertiesToLoad.Add("sn"); //Last name
            return searcher.FindOne(); //.FindAll() is also available, for example if you searching with name only //and there are chances of more than one user

in this way you can search the users from active directory, there are others properties are available to search for, you can google for it, if not found comment below, i will help.

August 26, 2012

Error: Server sent unexpected return value (405 Method Not Allowed)

Problem: Error: Server sent unexpected return value (405 Method Not Allowed)

Problem is while you add new folder to the SVN repository, then commit, above error is thrown.
This was occuring to me because of following Reason.

1) i created a new folder "Raj", then right clicked and from Tortoise Context menu, selected Add.
it showed added.
2) now when i tried to commit, the mentioned issue came.
3) Even it was not allowing me to undo the add, which i did on step1

after spending lot of time, i get to know, somebody in morning Added the folder with same name "Raj" in the repository.

My mistake was, i did not take the latest before adding the new folder.

if you are getting same issue, pls check via going to repo-browser that, Is it because of same reason, which i mentioned.

do comment below,  if it resolve or not resolve you issue.

January 26, 2012

Write server side asp .net code in tridion DWT

DWT has its own language, but sometime we need server side Tags in dwt tbb.

Example: Suppose you have some string and you want to format it, or want to do some operation on data which is not possible in DWT. you can use following code.



<% if(condtion) {%>

<%=String.Format("@@Variable@@","first","second")%>
<%="@@CAR@@".Replace("INR","Indian Rupee") %>
<% }%>


Keep in mind. DWT will no execute the .net code snippet, it will be rendered as its on .aspx page.

when this page is requested through browser then this asp.net code snippet executes.
& format or replace the strings etc.

if you have any question, just comment. i will try to reply ASAP






January 05, 2012

The breakpoint will not currently be hit. No symbols have been loaded for this document in visual studio in asp.net mvc or asp.net

this issue comes very often to the asp.net or asp.net mvc developer and it can waste considerable time. i have resolved this issue many times using following steps.

1) Check whether right version of code is being debugged. 
Go to iis right click on website. select open. Now match the path of this directory with the soution directory which is opened. it should match
2) Stop iis
3) Delete the temporary files form c:\windows\microsoft.net\framework\v2.0.50727\Temporary ASP.NET Files
4) Clean the solution (Right click -> clean
5) Rebuild the solution

now attach to w3c using ctrl+alt+p shortcut.