13 April 2018

PowerShell : Find user exist in AD -GROUP

Some times we do need to find users exist in AD group we assign any tickets and perform any activity
here is a sudo code i created in powershell to help you.

Code Step 1 Should be part of input


$cmdOutput = net group YOURADGROUPNAME /domain ;
$var = "USERNAME";



Code Step 2 : loop users and check for user



function finduser() {
for($i = 0; $i -lt $cmdOutput.Count; $i++) {
if($cmdOutput[$i] -eq $var){
$found="T"
write-host "--FOUND-->" $cmdOutput[$i]}
}
if($found -eq "T"){
write-host -ForegroundColor Green "Wow user found " $var}
else {
write-host -ForegroundColor Magenta "SORRY -Scanned records "$cmdOutput.Count " But " $var " not Found"
}
}

finduser



Angular 4/5 & SignalR connection


Signal R is one of the most widely used 

Step1:install i @aspnet/signalr-client --save
Step 2: include needed import in your component.

import { HubConnection } from '@aspnet/signalr-client';

now in your component

//HUB connection
this.connection = $.hubConnection(this.signalRURL);
this.connection.logging = true;
this.proxy = this.connection.createHubProxy('HUBNAME');

this.proxy.on('broadcastMessage', (data: any) => {
var msg = (JSON.parse(data)); Alert(msg); });
this.connection.start().done((data: any) => {
console.log(data.id);
}).catch((error: any) => {
this.connectionStatus = "Connection Failed";
console.log('Hub error -> ' + error);
});


 

15 November 2017

Angular build error : Hashingcrypto.js

Angular is for rapid development and its more frustrating with stuck on unconventional exception during build.
once of the instance I encounted was at hashingcryto.js failed at 86%

after ample research I figured a way to normalize the error to have more generic outcome to pin point troubleshoot.
all you need to do is find file HarmonyExportImportedSpecifierDependency.js which would be present at
  •   node_modules\webpack\lib\dependencies\HarmonyExportImportedSpecifierDependency.js
edit the file (pref. Notepad) and go to line number 144.
current function
updateHash(hash) {
        super.updateHash(hash);
        const hashValue = this.getHashValue(this.importDependency.module);
        hash.update(hashValue);
    }



replace with
updateHash(hash) {
super.updateHash(hash);
const hashValue = this.getHashValue(this.importDependency.module);

if (this.importDependency.module != null){
// console.log('Module resource: ', this.importDependency.module.resource);
}else{
console.log('\n Akx added Error File not found: ', this.importDependency);
}


now rebuild & vola you have gunned down the culprit to fix against

Hope this resolves your exception.



16 February 2017

SSIS & MS Dynamics CRM using Kingsway


Connecting to the CRM entities for loading or fetching data would be the tedious job if done from scratch, Kingsway ( Download from here ) came up with an intermediate connector to help or streamline the connectivity.
SET YOU DEV MACHINE
(1) Installed the Visual Studio (BITS) for BI development ( Download from here )
(2) Install the Kingsway SSIS Integration Toolkit for Microsoft Dynamics 365( Download from here )
(3) DataBase Driver which needs to be connected for data pull/push (SQL/ORACLE/MYSQL etc.)

Now we have the development environment set let connect to data sources:

For CRM connection:
(1) Right click on the connection manager
(2) Select new Connection
Select Type Dynamics CRM  (as Shown below)
Provide needed CRM URL and the Organization name 
Drop the Data Flow Task to perform needed BI operation
Within data Flow Task you will observe 3 new tool items added for dynamics CRM as shown below
Select desired based on the business needed, here I've selected as source which has the needed source type as an entity-entity name (source Entity)

For any further details please don't hesitate to drop an comment happy to respond 

08 February 2017

SSIS Script Task : ConnectionString for ADO.Net & OleDb ConnectionManager


In the switching world developer often needs to toggle between connection managers and wish the code operates as its expected.However, the execution engine is yet to be smart enough to undertake the difference.
Connection Manager TypeConnection Manager Name
ADOADO Connection Manager
MSOLAP90Analysis Services Connection Manager
EXCELExcel Connection Manager
FTPFTP Connection Manager
HTTPHTTP Connection Manager
ODBCODBC Connection Manager
OLEDBOLE DB Connection Manager

For those pin point here a code that worked for me and happy if works for you as well.
FOR ADO.NET Connection Manager

SqlConnection sConnection = new SqlConnection();
sConnection = (SqlConnection)(Dts.Connections["MyConnectionManagerADO.NETName"].AcquireConnection(Dts.Transaction) as SqlConnection);
var connection = sConnection.ConnectionString.ToString()


FOR OLEDB Connection Manager

var oConnection = Dts.Connections["MyConnectionManagerOLEDBName"].ConnectionString.ToString().Trim();
oConnection = oConnection.Replace("Provider=SQLNCLI10.1;", "").Replace("Provider=SQLNCLI11;", "").Replace("Provider=SQLNCLI11.1;", "").Replace("Auto Translate=False;", "");


31 December 2016

SSIS Exception Handling via script task C#

Writing a 'Script task' with c# code behind is a walk in the park, however, when the package is scheduled as Job the exception handling is vital key.
There are various permutations needs c# script is included to have needed outcome achieved.
Here is code snippet which can be included either in Catch block of try catch or as success/ failure condition as logic demands


try
{//your Code logic
}
catch (Exception ex)
{
Dts.Events.FireError(0, "- FAILED.", string.Concat("Oops! -", ex.Message.ToString(), "Inner Exception -",ex.InnerException.ToString() ), null, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}



09 March 2015

Elegant way to SWITCH & If Else





Switch Case is one of the most traditional way of having conditional break up performed. Here is the new way which directs, delegates and performs the action as needed.

Ideally I have seen developer opting for If Else statements, adding my source code were I need to set a check bit based on the parameter Range.



int mynumbercheck=1000;
//Your number to be checked
var myswitch = new Dictionary <Func<int,bool>, Action>
            { 
             { x => x < 10 ,    () => //Do this!...  },  
             { x => x < 100 ,    () => //Do this!...  },
             { x => x < 1000 ,    () => //Do this!...  },
             { x => x < 10000 ,   () => //Do this!... } ,
             { x => x < 100000 ,  () => //Do this!... },
             { x => x < 1000000 ,  () => //Do this!... } 
            };
Now to call our conditional switch

   myswitch.First(sw => sw.Key(mynumbercheck)).Value();

Hope this Help you and reduces if else code block

20 December 2014

Fetch Application Pool Identity





Web Application requires the database operation to be performed by service account which is configured in AppPool.
When ever the user hits the web application the request is received at IIS and CRUD operation is performed against database.

Here's my code snippet to have transaction performed by APPPool Identity

Add this code

using System.Runtime.InteropServices;
using System.Security.Principal;

private static WindowsIdentity _appPoolIdentity;
public static WindowsIdentity AppPoolIdentity
{
   get { WindowsIdentity result;
         if (_appPoolIdentity != null){result = _appPoolIdentity;}
         else {result = (_appPoolIdentity = GetAppPoolIdentity());}
         return result;
       }
}

[DllImport("advapi32.dll", SetLastError = true)]
private static extern bool RevertToSelf();
private static WindowsIdentity GetAppPoolIdentity()
{
       WindowsIdentity identity = null;
       Win32Exception win32Exception = null;
       Thread thread = new Thread(delegate(object o)
{
if (!Config.RevertToSelf())
 {
       int lastWin32Error = Marshal.GetLastWin32Error();
       win32Exception = new Win32Exception(lastWin32Error);
 }
  identity = WindowsIdentity.GetCurrent();
});
thread.Start();
thread.Join();
if (win32Exception != null)
{
       throw win32Exception;
}
return identity;
}


From your code just call the

using(AppPoolIdentity.Impersonate())
{
       //your Execution Block under AppPool Id
}

Hope this Helps you

09 September 2014

SQL Server Query :Sort Ordering Query

Sorting and re-ordering is one of the most common requirement in today's demanding industry and there are many approaches to achieve the same.

Here I'm sharing one of the easiest back-end solution to over come re-Ordering from database function/Store Procedure.

The advantage of having a database driven ordering would help is saving the processing call from application to database, & can have control over the functionality at ease.

Below shows the ordering after removing few titles.

 Current Ordering
----------------------
Title -- Order
Link 01-- 1
link 02 -- 2
link 03 -- 4
link 04 -- 6
link 05 -- 7
link 06 -- 8



To have current order in place we can have a database Function create to get corrected Ordering update to table /Column.
STEP 01 : GET CORRECT ORDER.

SQL function :  ROW_NUMBER()

Creating Code Block to get needed Ordering :
SELECT Title,SortOrder,
ROW_NUMBER() OVER (ORDER BY (select 1))
AS NEW_SORTORDER
FROM dbo.tablename

ROW_NUMBER needs to have Over followed ORDER BY attributes


STEP 02 : ORDER & UPDATE WITH TABLE

(a) Create a With Block
(b) Update with join on WITH black

WITH Correct_SortOrder AS
(
SELECT Title,SortOrder,
ROW_NUMBER() OVER (ORDER BY (select 1))AS NEW_SORT_ORDER
FROM dbo.tablename
)
Update
dbo.tablename
SET
dbo.tablename.SortOrder=Correct_SortOrder.NEW_SORT_ORDER
FROM
tablename
INNER JOIN
Correct_SortOrder
ON
tablename.Title=Correct_SortOrder.Title;




Hope this Help you. Happy Coding :)

26 September 2013

Failed to initiate the upgrade sequence. An exception of type System.IO.IOException was thrown.

"Failed to upgrade SharePoint Products."


I have installed the office web app patch & re-run the configuration wizard when I encountered this exception 

Please Note the GUID is vital for clearing cache.


  1. Stop the Timer service. To do this, follow these steps:
    1. Click Start, point to Administrative Tools, and then click Services.
    2. Right-click SharePoint 2010 Timer, and then click Stop.
    3. Close the Services console.
  2. On the computer that is running Microsoft SharePoint Server 2010 and on which the Central Administration site is hosted, click Start, click Run, type explorer, and then press ENTER.
  3. In Windows Explorer, locate and then double-click the following folder:
  4. %SystemDrive%\ProgramData\Microsoft\SharePoint\Config\GUID
  5. Notes
    1. The %SystemDrive% system variable specifies the letter of the drive on which Windows is installed. By default, Windows is installed on drive C.
    2. The GUID placeholder specifies the GUID folder. There may be more than one of these.
    3. The ProgramData folder may be hidden. To view the hidden folder, follow these steps:
      1. On the Tools menu, click Folder Options.
      2. Click the View tab.
      3. In the Advanced settings list, click Show hidden files and folders under Hidden files and folders, and then click OK.
      4. You can also simply type this directly in the path if you do not want to show hidden files and folders.
  6. Back up the Cache.ini file. (Make a copy of it. DO NOT DELETE THIS FILE, Only the XML files in the next step)
  7. Delete all the XML configuration files in the GUID folder (DO NOTE DELETE THE FOLDER). Do this so that you can verify that the GUID folders content is replaced by new XML configuration files when the cache is rebuilt.
    Note When you empty the configuration cache in the GUID folder, make sure that you do NOTdelete the GUID folder and the Cache.ini file that is located in the GUID folder.
  8. Double-click the Cache.ini file.
  9. On the Edit menu, click Select All.
  10. On the Edit menu, click Delete.
  11. Type 1, and then click Save on the File menu. (Basically when you are done, the only text in the config.ini file should be the number 1)
  12. On the File menu, click Exit.
  13. Start the Timer service. To do this, follow these steps:
    1. Click Start, point to Administrative Tools, and then click Services.
    2. Right-click SharePoint 2010 Timer, and then click Start.
    3. Close the Services console.
  14. Note The file system cache is re-created after you perform this procedure. Make sure that you perform this procedure on all servers in the server farm.
  15. Make sure that the Cache.ini file in the GUID folder now contains its previous value. For example, make sure that the value of the Cache.ini file is not 1.
  16. Check in the GUID folder to make sure that the xml files are repopulating. This may take a bit of time.
--------------------------------------------------------------


18 July 2013

SharePoint-GridView & PeopleEditor control.

Developer usually invest much time when the control are sharepoint and binding data is not made straight forward.

Below is simple example to get SharePoint:PeopleEditor control in SPGridView Control on application page.

Step 01:  Add SPGridView control on Application /Webpart page.
Step 02:  Add needed columns in the Sp GridView
Step 03 : Add Sharepoint PeopleEditor column
Step 04:  Add Title Property in PeopleEditor with binded column from data source
 Ex: -   Title='<%# Bind("AUTHOR") %>'
Step 05: Add OnRowDataBound property in SPGridView
Ex : - OnRowDataBound="spGridViewRowEventHandler"
Step 06: Add your picker validate code to resolve the user/Author on databound.

protected void spGridViewRowEventHandler(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {              
                PeopleEditor ppAuthor = (PeopleEditor)e.Row.FindControl("Control");
                string userid= ppAuthor.Title.ToString();
                 ppAuthor.CommaSeparatedAccounts =userid
                 ppAuthor.Validate();
            }

        }


That's it your control is done

21 March 2013

SharePoint People-picker Slowness

Recently my SharePoint portal seems to slowing from end user information entering. The User entry box people-picker was really taking forever to resolve name. The slowness was recorded across whole site collection and there was no customization involved which might have affected this issue.

In order to resolve this slowness following steps needs to be performed.
1. Execute following command on the WFE server.

 Stsadm–o setapppassword –password 

Please note - the password here is not the server.

2. Now execute following command on APP server.

Stsadm –o setproperty –pn peoplepicker -searchadforests –pv "forests:i.domain.com, Domain:i.domain.com" -url "http://Sharepointsite/"


This will do the trick. repeat same for Sub-site as well.


05 March 2013

SharePoint User Profile Synchronization.


SharePoint portals are tightly integrated with Active Directory and since SharePoint has a additional Database to maintain user profiling, However many times user alias names are shown inconsistent on welcome.ascx section For some it's show :
•         first name , last name
•         last name, first name 
•         domain\userID 
 This means AD-Profile Synchronization is not enabled or not happening for some reasons.
SOLUTION:

Manually run following SharePoint PowerShell Command which synchronizes AD Accounts.

Get-SPUser –Web http://SharePointServer | Set-SPUser –SyncFromAD

Execute command for each Site collection to reflect these changes.  

15 February 2013

SharePoint Error :The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service

InfoPath forms are giving following exception when trying to activate or add any new workflow
“The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator.”

 Solution : 

As I checked for the found State Service was not started, in order to start this service go to:

  1. Central administration  
  2. Configuration Wizards 
  3. Click “Launch the Farm Configuration Wizard” 
  4. click  “Start the Wizard”

To confirm state services is started go to
1. Application Management >>
2. Manage service applications you will see the status. 

01 November 2012

Silverlight and SharePoint connection with MVVM

  BasicHttpBinding binding = new BasicHttpBinding();
                EndpointAddress Address = new EndpointAddress(new Uri("http:///_vti_bin/lists.asmx"));
                // Required to initialize variables        

                ListsSoapClient proxy = new ListsSoapClient(binding, Address);
                proxy.GetListItemsCompleted += new EventHandler(proxy_GetListItemsCompleted);
                
                //Define the parameters for the service call
                XElement query = new XElement("Query");
                XElement queryOptions = new XElement("QueryOptions");
                XElement viewFields = new XElement("ViewFields");

                proxy.GetListItemsAsync("",
                    null,
                    query,
                    viewFields,
                    null,
                    queryOptions,
                    null);

Handler :

void proxy_GetListItemsCompleted(object sender, GetListItemsCompletedEventArgs e)
        {
            XDocument doc = XDocument.Parse(e.Result.ToString());

            var rst = from item in doc.Descendants(XName.Get("row", "#RowsetSchema"))
                      select new OpenTktValue
                      {
                          Column1 = item.Attribute("ows_Column1").Value.ToString(),
                          ColumnN = item.Attribute("ows_ColumnN").Value.ToString()
                      };

            rst.First().Column1.ToString() + "-" + rst.First().Column1.ToString());
        }

04 October 2012

SharePoint 2010 -SVC service Exception :'System.Data.Services.Providers.IDataServiceUpdateProvider'

SharePoint 2010 has List data web service However many users trying to access get following exception :   http://yoursite/_vti_bin/ListData.svc

Could not load type 'System.Data.Services.Providers.IDataServiceUpdateProvider' from assembly 'System.Data.Services, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Remedy:

Installation needed on SharePoint web front end servers: ADO.NET Data Services Update for .NET Framework 3.5 SP1 for Windows 7 and Windows Server 2008 R2

Click to Download -- ADO.NET Data Services Update for .NET Framework.

18 September 2012

Remove line with keyword from Text file :C#

Requirement : Huge text file needs to be parsed and the output file needs should eliminate
lines having special characters/words.

Solution: This is a 3 step solution : (1) reade file (2) Parse File with key word
(3) Output as required



Declare Source & Destination file - Setting parameter:



    string _SourceFile= @"c:\Sample_IN.txt";
    string _DestinationFile= @"c:\Sample_OUT.txt"; 


// Reading Source file



            string line =string.Empty; 
            StringBuilder StrBld= new StringBuilder();
            WrdFound = true; 
            //READ the file and display it line by line. System.IO.StreamReader
            file = new System.IO.StreamReader(filename); 
            while ((line = file.ReadLine()) !=
            null) 
            { if (!(line)) 
            StrBld.AppendLine(line.Replace(' ',',')); 
            } 


//CHECK Key word against which the line to be dropped Ex my key words are "AKSHAYA"
or "MASHANKAR")




            CheckKeyWord(string _eachLine) 
            { 
            if (_eachLine == null || _eachLine.Length
            == 0) return false; else 
            { Regex regex = new Regex(@"(AKSHAYA|MASHANKAR)", RegexOptions.IgnoreCase);
            return regex.IsMatch(_eachLine); } 
            } 


//WRITING DESTINATION File



//WRITE the file and display it line by line.
 using (StreamWriter sw = new StreamWriter(tempFilename))
 {
    sw.WriteLine(StrBld.ToString());
 }
file.Close();



Please share your thoughts and comments for the dame



28 July 2012

SharePoint 2010 -MS LYNC Integration.

SharePoint - a collaborative platform to have mash up functional is always fun. Recently I found can across well drafted article published by J.D. Wade on Sharepoint and Microsoft Lync.

Lync and SharePoint Integration

Special thanks : J.D Wade.

21 July 2012

ORACLE : WITH Block statement

Query writing is fun but can be complex when we are referring multiple tables/views which has inlet/Joins /sub-query referred. on the best solution & organized way of writing such query in Oracle is using WITH Blocks.
Below I'm using simple example to help you get started with WITH-blocks
Tutorial : First block starts with "WITH" keyword  
WITH block_name AS ( ), Final statement includes Select statement with in query or join as needed treating each block as table. Below are 2 example showing with block usage.

Example : Consider 4 tables/views having needed information blinded with a connecting factor and say ID. Normal Query States :

        SELECT T1.Col1, T1.col2, T2.col3, T2.col4,
T2.col5 FROM Table1 T1 JOIN Table2 T2 ON Col6 = col7 
WHERE col6 IN ( SELECT TA.COLA FROM TableA TA JOIN TableB TB ON TA.COLA1 = tb.ColB1 ) 
Now to have more organized way to get this query executed using WITH Block  

CONDITION 01: Using blocks in WHERE clause
        WITH BLOCK1 AS (SELECT TA.COLA FROM
  TableA TA JOIN TableB TB ON TA.COLA1 = tb.ColB1), 
SELECT T1.Col1, T1.col2, T2.col3, T2.col4, T2.col5 FROM Table1 T1 JOIN Table2 T2 ON Col6 = col7 WHERE col6 IN 
( --Note:with block added as select statement & can be used at multiple places. 
SELECT block1.cola FROM BLOCK1 
) 

CONDITION 02: JOINING WITH blocks all together.
--Note : block starts from "WITH" statement
        WITH BLOCK1
AS
(SELECT TA.COLA FROM TableA TA JOIN
TableB TB ON TA.COLA1 = tb.ColB1 
), 
--Note: Except last with block all with block end with , 
BLOCK2 AS ( 
SELECT T1.Col1, T1.col2, T2.col3, T2.col4, T2.col5 FROM Table1
T1 JOIN Table2 T2 ON Col6 = col7 
) 
--final statement only includes Black name. 
SELECT * FROM Block2 B2, Block1 B1 WHERE B2.col6 = b1.COLA
  
Hope this help's you ----

14 March 2012

Power Shell Command finder links

Couple of helpful links for Powershell links to refer

SilverLight Command Builder

Index of SharePoint Server 2010 Windows PowerShell cmdlets

Codeplex PS tool (directions on the site)

Finally for Remote Server Execution of powershell commands best mentioned steps:
SharePoint 2010 with Windows PowerShell Remoting Step by Step

Hope this helps you as well.


Rate Now: