Posts

Showing posts from 2012

Access Edge service failed to start: Transport TLS has failed to start on local IP address

When we get the below errors in the event viewer on the edge service: A configured transport has failed to start. Transport TLS has failed to start on local IP address 10.x.x.x at port 5061. Cause: Configuration error, low system resources or another program is using the specified port. Can also happen if the IP address has become invalid. Resolution: Ensure that the IP address specified is valid and that no other program is listening on the specified port. Unable to bind for socket. Transport:TLS, IP address: 10.x.x.x, Port:5061. Error:0x80072741 (The requested address is not valid in its context.). Resolution: Ensure that no other program is listening to the specified port and that the IP address is valid. Then most probably the error can be that your IP address got changed and the topology builder is still using the old IP address. This can happen when you are using DHCP instead of static assigning. Resolution: Change the IP in the topology using the topology build

Topology builder mmc crash (Lync server installation)

When we are about to publish topology, if MMC crashes then the probable reason  might be wrong AD preparation. For this first of all remove the configuration store  location and then publish the topology after selecting thee correct CMS     Remove-CsConfigurationStoreLocation

Sending a mail with image in the message body

EmailMessage message = new EmailMessage (exchangeService); message.Subject = "test"; message.Attachments.AddFileAttachment( @"test.bmp" ); message.Attachments[0].ContentId = test.bmp@123 ; message.Attachments[0].IsInline = true ; message.Attachments[0].ContentLocation = path; //Image path Without content location and ContentId we will not get the image in the message body. Make sure you add the Content ID in the HTML to get the image.

Cannot load Counter Name data because an invalid index '' was read from the registry

If you are unable to get the performance metrics of a machine: Running this command from command prompt may help: lodctr /r Check if all are enabled: lodctr /q

Interview questions

1) What are constraints? These are used to constraint(limit) the data that can go into SQL tables There are generally six types of constraints in SQL: NOT NULL Constraint - Check Constraint - Default Constarint - Primary Key Constraint - Unique Key Constraint - Foreign Key Constraint - 2) What are ACID properties? ACID stands for Atomicity, Consistency, Isolation and Durability. Database professionals when evaluating the database, looks at these features of database. Atomicity: Each transaction is said to be atomic. If one part of the transaction fails, entire transaction should fail. Its all or none rule. Consistency: Only valid data should be written into database. If a transaction is executed that violates the Database consistency rules then entire transaction should be rolled back. Database should not leave your transaction in half finished state. Isolation: Database should isolate two concurrent transactions until they are finished. Durability: Any transac

Lync and Exchange UM integration

For this I found a very useful post and here is the link to follow: http://blog.schertz.name/2010/11/lync-and-exchange-um-integration/ and ofcourse the microsoft link is also very useful: http://technet.microsoft.com/en-us/library/bb803622(office.12).aspx

Is not recognized as a valid cmdlet!!!

When we install Lync Server and try to import, export or use some other cmdlets, make sure you use Lync server management shell. If you use windows powersell then we will get the errors as mentioned in the title.. Silly but i did it few times this way :)

Installing Lync Server 2010

For installing Lync server topology, i want to brief down some points which will be useful in installing : 1) In wave 13(OCS 2007 R2) we can install AD and OCS on the same machine but Lync server 2010 doesnt allow it. We need to install AD on a separate machine first by using dcpromo. 2) Then next task will be installing AD components of Lync server on AD machine. 3) If you are opting for enterprise edition, install SQL Server on a separate machine. Else just skip this step. 4) Now on another machine from the Lync server deployment wizard install First standard or Enterprise edition. 5) On the same machine install topology builder. From -> All Programs, open topology builder and build a topology. After that publish the topology. For EE, we need to point to SQL server for CMS. And important point here is every organisation irrespective of number of SE and EE pools, a forest can contain only one Central management Store. So if you are planning for a child domain and in

How Voicemail will be reached to a OCS/Lync User??

I did so many settings in the Exchange and Lync to configure the voicemail. Ofcourse i successfully did it but i just followed some documents. After reading this link i felt myself relaxed by understanding the basic concept.. http://www.ocspedia.com/Misc/How_OCS_Selects_UM_Server.aspx

WCF

BareMessage=Unrecognized configuration section system.servicemodel. Edit system.servicemodel to system.serviceModel to solve this issue. This error can also cause if machine.config file doesn't have the system.serviceModel section.

WCF

An error occurred when verifying security for the message If you are running Client and Service on one machine successfully and when you are running service on one machine and client one machine there is a possibility of receiveing the above message. For this we need to have the following stuff in the code: proxy.ClientCredentials.Windows.ClientCredential.UserName = "user"; proxy.ClientCredentials.Windows.ClientCredential.Password = "password"; proxy.ClientCredentials.Windows.ClientCredential.Domain = "domain";

WCF Error

Unable to connect to the remote server Even after giving the correct service IP and port in the config file, if you face the above error then the probable problem may be that when the service is published as "localhost". Try to change it to the IP of the machine name and try. Note:The time on the machines where client and service are running should be in sync

Sorting - Bubble Sort

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AsscendingOrder { class Program { static void Main(string[] args) { int[] a = { 2,1,2,1,2,13,19,31,6}; for (int j = a.Length - 1; j > 0; j--) { for (int i = 0; i < j; i++) { if (a[i] > a[i + 1]) { int temp = a[i]; a[i] = a[i + 1]; a[i + 1] = temp; } } } for (int i = 0; i < a.Length; i++ ) Console.WriteLine(a[i]); Console.ReadLine(); } } }

Hex to Decimal

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace HexToDec { class Program { static void Main(string[] args) { string hex = Console.ReadLine(); int Total = 0; //TBD: Need to check for other characters are entered for (int i = 0; i <= hex.Length - 1; i++) { switch (Convert.ToChar(hex[i].ToString().ToUpper())) { case 'A': Total = Total + 10*((Int32)Math.Pow(16,hex.Length-1-i)); break; case 'B': Total = Total + 11 * ((Int32)Math.Pow(16, hex.Length - 1 - i)); break; case 'C': Total = Total + 12 * ((Int32)Math.Pow(16, hex.Length - 1 - i)); break; case 'D': Total = Total + 13 * ((Int32)Math.Pow(16, hex.Length - 1 - i)); break; case 'E': Total = Total + 14 * ((Int32)Math.Pow(16, hex.Length - 1 - i)); break; case 'F': Total = Total + 15 * ((Int32)Math.Pow(16, hex.Length - 1 - i)); break; default: Total = Total + Convert.ToInt32(hex[i].ToString()) * ((Int

Second max element in a array

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SecMax { class Program { static void Main(string[] args) { int[] arr = { 10000, 2000, 300, 200, 1, 50, 56, 72 }; //assumption: no 2 numbers will be equal. That part is not covered if (arr[0] < arr[1]) { int temp = arr[0]; arr[0] = arr[1]; arr[1] = temp; } for (int i = 2; i <= arr.Length - 1; i++) { if (arr[i] >= arr[0]) { arr[0] = arr[i]; } else if (arr[i] >= arr[1]) { arr[1] = arr[i]; } } Console.WriteLine(arr[0]); Console.WriteLine(arr[1]); Console.ReadLine(); } } }

Binary Search Tree Operations

#include "iostream" #include "cstdlib" using namespace std; class BinarySearchTree { private: struct tree_node { int data; tree_node* left; tree_node* right; }; tree_node* root; public: BinarySearchTree() { root = NULL; } void Print_PreOrder(); void Print_PostOrder(); void Print_InOrder(); void inorder(tree_node*); void preorder(tree_node*); void postorder(tree_node*); void insert(int); }; void BinarySearchTree::insert(int d) { tree_node* current = new tree_node; current->data = d; current->left = NULL; current->right = NULL; tree_node* parent; parent = root; tree_node* temp; if(root == NULL) { root = current; } else { while(parent) { temp = parent; if(current->data > parent->data ) { parent = parent->right; } else { parent = parent->left; } } if(current->data > temp->data) { temp->right = current; } else { temp->left = current; } } } void Bina

C# - Reference Example

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace reference { class Program { static void Main(string[] args) { int i = 5; Method(ref i); Console.WriteLine(i.ToString()); Console.ReadLine(); } static void Method(ref int j) { j = j + 7; } } }

string reverse

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace stringreverse { class Program { static void Main(string[] args) { string first; int j=0; Console.WriteLine("Enter the first string"); first = Console.ReadLine(); char[] firstArr = first.ToCharArray(); char[] secondArr = first.ToCharArray(); for (int i = first.Length - 1; i >= 0; i--) { secondArr[j] = firstArr[i]; j++; } Console.WriteLine(secondArr); Console.ReadLine(); } } }

reverse word C++

#include "iostream" #include "string" using namespace std; int main() { string first; //with spaces this will not work cout<<"Enter the first word"; cin>>first; const char * cs = first.c_str (); while(*cs) { cs++; } cs--; while(*cs) { cout<<(*cs); cs--; } cin>>first; }

Base Class and Derived Class

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BaseDerived { class Program { static void Main(string[] args) { BaseClass bc = new BaseClass(); bc.fn(); BaseClass bcd = new DerivedClass(); bcd.fn(); DerivedClass d = new DerivedClass(); d.fn(); Console.ReadLine(); } } class BaseClass { public virtual void fn() { Console.WriteLine("Base"); } } class DerivedClass: BaseClass { public override void fn() { Console.WriteLine("Derived"); } } }

Constructor, Destructor and Virtual Destructor

Comment either base or derived objects in the main function and see the variation in the output. For virtual destructor concept remove the virtual keyword for base class destructor and see the output. #include "iostream" using namespace std; class BaseClass { public: BaseClass() { cout<<"Base Class constructor"< } virtual ~ BaseClass() { cout<<"Base Class Destructor"< } }; class DerivedClass :public BaseClass { public: DerivedClass() { cout<<"Derived Class Constructor"< } ~ DerivedClass() { cout<<"Derived Class Destructor"< } }; int main() { char ch; BaseClass *bc = new BaseClass() ; DerivedClass *dc = new DerivedClass(); BaseClass *bcd = new DerivedClass(); delete bc; delete dc; delete bcd; cin>>ch; }

Factorial using Recursion C#

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Factorial { class Program { static void Main(string[] args) { Console.WriteLine(factorial(4)); Console.ReadLine(); } static int factorial(int n) { if (n > 1) { return factorial(n - 1) * n; } else { return 1; } } } }

Least Common Ancestor

#include "iostream" using namespace std; class LcaClass { struct Node { int data; Node* left; Node* right; }; Node* root; public: LcaClass() { root = NULL; } void insert(int data); int lca(int first, int second); }; void LcaClass::insert(int data) { Node* current = new Node; current->data = data; current->left = NULL; current->right = NULL; Node* parent = root; Node* temp = NULL; if(parent == NULL) { root = current; parent = root; } else { while(parent) { temp = parent; if(data > parent->data) { parent = parent->right; } else { parent = parent->left; } } if(temp->data > data) { temp->left = current; } else { temp->right = current; } } } int LcaClass::lca(int firstvalue,int secondvalue) { if(root == NULL) { cout<<"root value is NULL"< return 0; } while(root) { if(root->data > firstvalue && root->data > secondvalue) { root = root->left; } else if(root->data <= firstvalue && root->

Reversing words in a string- Method 1

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ReverseString { class Program { static void Main(string[] args) { string test = "Hi How are you"; int len = test.Length; int i = 0; int j = 0; int k = 0; int l = 0; bool spaceOccurred = false; char[] charArray = test.ToCharArray(); char[] finalArray = test.ToCharArray(); char[] reverseArray = test.ToArray(); for (i = len-1; i >= 0; i-- ) { finalArray[j] = charArray[i]; j++; } string finalString = new string(finalArray); Console.WriteLine(finalString); for (i = 0; i < len; i++) { if (finalArray[i] == ' ') { if (!spaceOccurred) { for (k = i-1; k >= 0; k--) { if (finalArray[k] != ' ') { reverseArray[l] = finalArray[k]; l++; } else { break; } } reverseArray[l] = ' '; l++; spaceOccurred = true; } else { reverseArray[l] = ' '; l++; } } else { spaceOccurred = false; } } for (i =

Reversing Words - Method 2

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ReverseString { class Program { static void Main(string[] args) { string test = "Hi How are you "; int len = 0; char[] charArray = test.ToCharArray(); char[] finalArray = test.ToCharArray(); int i = 0; int j = 0; int k = 0; bool spaceOccurred = false; foreach (char ch in charArray) { i++; } len = i; for (i = len-1; i >= 0; i--) { if (charArray[i] == ' ' || i == 0) { if (!spaceOccurred || i == 0) { if (i == 0) { i = -1; } for (k = i+1; k != len && charArray[k] != ' '; k++) { finalArray[j] = charArray[k]; j++; } if (i != -1) { finalArray[j] = ' '; j++; } spaceOccurred = true; } else { finalArray[j] = ' '; j++; } } else { spaceOccurred = false; } } Console.WriteLine(finalArray); Console.ReadLine(); } } }

Error: Identifier not found

Below example throws a error saying "Identifier not found" even when both the functions are defined above main because "even" is not visible from "odd" method. Therefore it is a good practice to declare all the methods above the main and define the methods below the main. For the code to work uncomment the commented lines and move the 'odd' and 'even' methods below the main(). #include using namespace std; //void odd (int a); //void even (int a); void odd (int a) { if ((a%2)!=0) cout << "Number is odd.\n"; else even (a); } void even (int a) { if ((a%2)==0) cout << "Number is even.\n"; else odd (a); } int main () { int i; do { cout << "Type a number (0 to exit): "; cin >> i; odd (i); } while (i!=0); return 0;

First repeated character

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace FirstNonRepeatingCharacter { class Program { static void Main(string[] args) { bool[] arr = new bool[256]; bool repeated = false; Console.WriteLine("Enter the string" ); string str = Console.ReadLine(); if (str.Equals("")) { Console.WriteLine("String is null"); Console.ReadLine(); return; } foreach (char ch in str) { if (!arr[(int)ch] == true) { arr[(int)ch] = true; } else { Console.WriteLine("First non repeated character: " + ch); repeated = true; break; } } if (repeated == false) Console.WriteLine("No repeated characters"); Console.ReadLine(); } } }

First repeated character

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace FirstRepeatedCharacter1 { class Program { static void Main(string[] args) { Console.WriteLine("Enter the string"); string str = Console.ReadLine(); if (str == "") { Console.WriteLine("string is empty"); Console.ReadLine(); return; } bool repeated = false; Hashtable strhash = new Hashtable(); foreach (char ch in str) { if (strhash.ContainsValue(ch)) { Console.WriteLine("First non repeated character: " + ch); repeated = true; break; } else { strhash.Add((int)ch, ch); } } if (repeated == false) { Console.WriteLine("No repeated characters"); } Console.ReadLine(); } } }

Two strings are given, remove all occurrences or the characters in the second string from the first string

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace RemoveRepeatedCharacters { class Program { static void Main(string[] args) { Console.WriteLine("Enter the orirginal string"); string str = Console.ReadLine(); Console.WriteLine("Enter the characters to be removed string"); string rem = Console.ReadLine(); Hashtable remhash = new Hashtable(); foreach (char ch in rem) { if (!remhash.ContainsValue(ch)) { remhash.Add((int)ch, ch); } } string final = ""; foreach (char ch in str) { if (!remhash.ContainsValue(ch)) { final = final + ch; } } Console.WriteLine(final); Console.ReadLine(); } } }

Maximum times repeated character

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace MaxRepeatedCharacters { class Program { static void Main(string[] args) { int max = 0; Console.WriteLine("Enter the string"); string str = Console.ReadLine(); char maxRepeatedCharacter = str[0]; if (str == "") { Console.WriteLine("String is empty"); Console.ReadLine(); return; } Hashtable hash = new Hashtable(); foreach(char ch in str) { if (hash.ContainsKey(ch)) { hash[ch] = (int)hash[ch] + 1; if ((int)hash[ch] > max) { maxRepeatedCharacter = ch; max = (int)hash[ch]; } } else { hash.Add(ch, 1); } } Console.WriteLine("Max repeated character is: " + Convert.ToString(maxRepeatedCharacter)); Console.ReadLine(); } } }

Expression Validator using Stack

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace ExpressionValidator { class Program { static void Main(string[] args) { Console.WriteLine("Enter the string"); string input = Console.ReadLine(); if (IsInputValid(input)) { Console.WriteLine("Expression is valid"); } else { Console.WriteLine("Expression is not valid"); } Console.ReadLine(); } static bool IsInputValid(string input) { Stack s = new Stack (); foreach (char ch in input) { if (ch == '(' || ch == '{') { s.Push(ch); } else { if (ch == ')' || ch == '}') { char poppedItem = s.Pop(); if ((ch == ')' && poppedItem == '(') || (ch == '}' && poppedItem == '{')) { continue; } else { return false; } } } } if (s.Count != 0) return false; return true; } } }

ReverseLinkedList

#include using namespace std; class LinkedList { private: struct Node { int data; Node *next; }; Node *root; public: LinkedList() { root = NULL; } void insert(int); void Print(); void Reverse(); }; void LinkedList::insert(int d) { Node* current = new Node; current->data = d; current->next = NULL; Node* parent; parent = root; Node* temp; if(root == NULL) { root = current; } else { while(parent) { temp = parent; parent = parent->next; } temp->next = current; } } void LinkedList::Print() { Node* temp; temp = root; while(temp) { cout< data< temp = temp->next; } } void LinkedList::Reverse() { Node* temp; Node* previous; bool first = true; while(root) { temp = root->next; if(first) { first = false; root->next = NULL; } else { root->next = previous; } previous = root; root = temp; } root = previous; } int main() { LinkedList ll ; int choice, value; do { cout<<"Insert the elements"< cin>>value; ll.insert(value); cout<<"