Showing posts with label Sharepoint 2010. Show all posts
Showing posts with label Sharepoint 2010. Show all posts

Thursday, December 18, 2014

Migrating user accounts from one AD domain to another AD Domain using Powershell

Got the opportunity to migrate the users from one domain to another domain. Users should migrate in Nintex DB too.

$nwcmd = 'C:\Program Files\Nintex\Nintex Workflow 2010\NWAdmin.exe'
$nwarg1 = '-o'
$nwarg2 = 'MigrateUser'
$nwarg3 = '-oldUser'
$nwarg4 = '-newUser'
$errorstatus=$ErrorActionPreference

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea silentlycontinue

$m = [Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager]::Local
Function Get-SPClaim {
    param ([string]$user)
    $claim = New-SPClaimsPrincipal -identity $user -IdentityType "WindowsSamAccountName"
    return $m.EncodeClaim($claim)
}



function MigrateUserOrGroups($migrationType, $csvFile)
{
   #Getting the SPFarm object
   $farm = Get-SPFarm

   Write-Host $migrationType
   #Checking whether the user input the type of Migration as Group
   if($migrationType -eq "Group"){
   Import-Csv $csvFile | ForEach-Object{
      Write-Host "Migrating Group" $_.oldlogin "to" $_.newlogin -ForegroundColor Green
      $farm.MigrateGroup($_.oldlogin, $_.newlogin)
     
       }
      }
     
    #Checking whether the user input the type of Migration as User
    if($migrationType -eq "User")
    {

        Import-Csv $csvFile | ForEach-Object{
       
        $olduser= Get-SPClaim($_.oldlogin);
            $newuser= Get-SPClaim($_.newlogin);
            $oldloginname=$_.oldlogin
            try
            {
                $ErrorActionPreference="stop"
               
                Write-Host $newuser
                Write-Host "Migrating User" $_.oldlogin "to" $_.newlogin -ForegroundColor Green
                $farm.MigrateUserAccount( $olduser, $newuser, $false )
                write-host $nwcmd $nwarg1 $nwarg2 $nwarg3 """$olduser""" $nwarg4 """$newuser"""
                & $nwcmd $nwarg1 $nwarg2 $nwarg3 $olduser $nwarg4 $newuser
               
             }
             catch
             {
                write-host "Exception occured for migrating user"  $oldloginname " Message: $($_.Exception.Message)" -ForegroundColor Red
             }
             finally
             {
                $ErrorActionPreference=$errorstatus
             }
               
        }    
    }
     
   Write-Host "Migration Completed" -ForegroundColor Cyan
 
 
 
}

MigrateUserOrGroups $args[0] $args[1]
Follow below links
http://blogs.msdn.com/b/sowmyancs/archive/2012/01/07/migrate-users-groups-powershell-script.aspx?PageIndex=2
http://sharepoint.stackexchange.com/questions/118424/how-to-migrate-ad-domain-groups-in-sharepoint-2010

Friday, March 23, 2012

How to retrieve user data from Active Directory in SharePoint 2010 using C#

Requirement:
In SharePoint logged in user can click on chat button to communicate with IT Help desk team.
In this requirement we need to pass users login name,IP Address, Country and City of the user to the Help desk team. The team using the Provide Support Chat tool.

Solution:
Have developed a web part to deploy in SharePoint 2010.

User name and IP Addresses are coming from the below statements in the user control.
lblUserName.Text= Request.ServerVariables["LOGON_USER"];
lblIP.Text = Request.ServerVariables["REMOTE_ADDR"];
The Country ,City and other properties coming from AD
using System.DirectoryServices;
findBase.Add("LDAP://XXX/OU=Users,OU=Bangalore-CRL,OU=Pacific Asia,DC=corp,DC=lairdtech,DC=com");
findBase.Add("LDAP://XXX/OU=Users,OU=Sharepoint Users,DC=corp,DC=lairdtech,DC=com");
(Collection of LDAPs)
foreach (string str in findBase)
{
DirectoryEntry myLdapConnection = createDirectoryEntry(str);
// create search object which operates on LDAP connection object
// and set search object to only find the user specified
DirectorySearcher search = new DirectorySearcher(myLdapConnection);
search.Filter = "(cn=" + userName + ")";
SearchResult result = search.FindOne();
if (result != null)
{
if (result.Properties["c"].Count > 0)
userDetails.Add(result.Properties["c"][0].ToString());
else
userDetails.Add("");
if (result.Properties["l"].Count > 0)
userDetails.Add(result.Properties["l"][0].ToString());
else
userDetails.Add("");
break;
}
// else Console.WriteLine("User not found!" +i.ToString());
}
return userDetails;
public DirectoryEntry createDirectoryEntry(string findBase)
{
// create and return new LDAP connection with desired settings
DirectoryEntry ldapConnection = new DirectoryEntry(findBase, "corp\\NA-Service", "0ZLXXXGKXXX");
ldapConnection.AuthenticationType = AuthenticationTypes.Secure;
return ldapConnection;
}
Next passing the user details to the chat tool

Once user clicks on the chat button then Help desk team receives the users details like the below screen shot

Finally have deployed the IT Help desk chat web part on the home page the sharepoint 2010.
Useful Links:

Monday, October 10, 2011

How to configure PDF iFilter for SharePoint Server 2010 or Search Server 2010

For one of my requirement used the below url for configuring iFilter for SharePoint 2010.
Installation process
• Install iFilter
• Place Icon
• Modify registry
• Restart SP Search service

http://www.mossgurus.com/adnan/Lists/Posts/Post.aspx?ID=40

Wednesday, July 29, 2009

Installation of Sharepoint2010

Today i installed new version of Sharepoint in my testing box.
I am trying to get the new architectural changes in 2010.

Wednesday, July 15, 2009

SharePoint 2010 SneakPeek!

Now SharePoint 2010 Era has Began!
SharePoint 2010 Products and Technologies developer documentation dropped and is available for download here:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=94afe886-3b20-4bc9-9a0d-acd8cd232c24
SharePoint 2010 sneak peaks are now available here:
http://sharepoint.microsoft.com/2010/Sneak_Peek/Pages/default.aspx