Friday, 1 June 2012

Get the User Names from Active Directory using C#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
using System.DirectoryServices.AccountManagement;


namespace ConsoleApplication19
{
    class Program
    {
        static void Main(string[] args)
        {
            DirectoryEntry domain = new DirectoryEntry("LDAP://domainname.com/CN=Users,DC=domainname,DC=com");


            foreach (DirectoryEntry child in domain.Children)
            {
                Console.WriteLine(child.Name);
            }
            Console.WriteLine("----------------------------------------------------------");


            DomainCollection domains = Forest.GetCurrentForest().Domains;
            foreach (Domain domain1 in domains)
            {
                Console.WriteLine(domain1.Name);
            }
            Console.WriteLine("----------------------------------------------------------");
            DirectoryEntry domain2 = new DirectoryEntry("LDAP://domainname.com/CN=Computers,DC=domainname,DC=com");
            foreach (DirectoryEntry child1 in domain2.Children)
            {
                Console.WriteLine(child1.Name);
            }
            Console.ReadKey();
        }  
    }
}

SP 2010: Find error messages with a Correlation ID token in SharePoint 2010

Open PowerShell and type syntax as follows.... 

1.  PS C:\Users\Administrator> get-splogevent |?{$_.correlation -eq "e2455748-780d-4387-8b6d-812419a6403a"}|select area,cate
gory, level, eventid, message|format-list

2.  PS C:\Users\Administrator>get-splogevent | ?{$_.Correlation -eq "2872bd2d-a0a5-4cac-b218-f504a7d2a4c5"} | ft Category, Message -Autosize

Tools: 1. UlsViewer
          2. SPLogViewer

Developer Dashboard

Activating the Developer Dashboard

•    PowerShell 
•    STSADM.exe 
•    SharePoint Object Model (API's) 

Activate the Developer Dashboard using PowerShell:-
$devdash = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings; 
$devdash.DisplayLevel = 'OnDemand'; 
$devdash.TraceEnabled = $true; 
$devdash.Update() 

Activate the Developer Dashboard using STSADM.EXE:-
STSADM.EXE -o setproperty -pn developer-dashboard -pv ondemand

Activate the Developer Dashboard using the SharePoint Object Model:-
using Microsoft.SharePoint.Administration;
SPWebService svc = SPContext.Current.Site.WebApplication.WebService; 
svc.DeveloperDashboardSettings.DisplayLevel = 
    SPDeveloperDashboardLevel.Off; 
svc.DeveloperDashboardSettings.Update();

•    Off (Disables the Developer Dashboard) 
•    On (Enables the Developer Dashboard) 
•    OnDemand (Enables the Developer Dashboard upon request by clicking the icon in the upper right corner) 

SPMonitoredScope to track performance in your applications:-
 using (new SPMonitoredScope("Monitoring")) 

    Controls.Add(new Literal { Text = "When the awesomeness is flying... " }); 
                
    using (new SPMonitoredScope("Sub-Monitoring")) 
    { 
        Controls.Add(new Literal { Text = "Hello this is --Sub-Monitoring! " }); 

        using (new SPMonitoredScope("Sub-Sub-Monitoring")) 
        { 
            Controls.Add(new Literal { Text = "<br/>Hello this is Sub-Sub-Monitoring!" }); 
        } 

        using (new SPMonitoredScope("Sub-Sub-Monitoring_1")) 
        { 
            Controls.Add(new Literal { Text = "Hello this is Sub-Sub-Monitoring_1" }); 
        } 
    } 
}

Now go and test Doveloper Dashboard to find the Result with about scope names
0.Monitoring 
1. Sub-Monitoring
2. Sub-Sub-Monitoring
3. Sub-Sub-Monitoring_1

Property or indexer 'Microsoft.SharePoint.SPListItem.Title' cannot be assigned to -- it is read only

Property or indexer 'Microsoft.SharePoint.SPListItem.Title' cannot be assigned to -- it is read only :-



 protected void btn1_Click(object sender, EventArgs e)
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Announcements"];
                    SPListItem item = list.AddItem();
                    item["Title"] = "New Announcement";
                    item.Update();
                }
            }
        }


All About Workflow in SharePoint 2010


The Workflow status are constants (integers), So you'll need to refer to a list like:

1. Status: Value
2. Not Started: 0
3. Failed On Start: 1
4. In Progress: 2
5. Error Occurred: 3
6. Canceled: 4
7. Completed: 5
8. Failed On Start(Retrying): 6
9. Error Occurred (Retrying): 7
10. Canceled: 15
11. Approved: 16
12. Rejected: 17

So we need to check if Approval Status equals 17.

SharePoint Version


SharePoint Version


Activate My Sites in SharePoint Server 2010 Beta: HowTo


When you click the SharePoint Server 2010 Beta on the personal menu, is his My Site not available. Also missing (if the technical preview of the familiar SharePoint Server) on the Ribbon, the ability to assign tags and the "I like it."


To My Site and the related social media features (tags, I like it) up and running, you must first configure the profile import. How this is done in SharePoint Server 2010 Beta, I will explain in this blog post. When that's done, you can make to the My Site. This seems to be severely delayed in the current beta a bit. The rough steps are:

     Create a new MySite host and configure.
     The "User Profile Service" of the current web application to assign

1: First you need to create a new My Site host. This happens at about the same process as he made 
​​in SharePoint Server 2007th In the Central Administration you go to Application Management - Manage web applications. There, select from its Web application and selects the ribbon "Managed Path".



Here we define two "managed path". For "mysite" is an "Explicit Inclusion" created path. For the path of "personal" is a "wildcardinclusion" is created.


3: Then you go back to Application Management. There, select Site Collections - Create site collections. The menu to create a new site opens. The name of the site does not matter (mysitehost for example). Under "Web Site Address" but you have to "mysite" (as defined in Step 1) Select. As a template is chosen in the tab "Enterprise" "My Site Host."

3: Now you must enter the correct configuration MySite still a small beta error and the new My Site host. To be navigated in the Central Administration - Application Management - Manage service applications - User Profile Service Application and then under My Site settings - Setup My Site.
In the configuration of the entries are corrected MySite "My Site Host" to "http://server1:80/mysite" and "Personal Site Location" to "personal". At the same time removing the "Read Permission Level" to the cryptic user, so that only the SharePoint admin account or another administrator is listed.

mysite_5



As you can see in step 3, the My Site in SharePoint Server 2010 is run via the "User Profile Service". But this is not allocated in the current beta of the web application. To do this, one must return again to the configuration of its web application. In the Central Administration you go to Application Management - Manage web applications. There, select from its Web application and selects the ribbon "Service Connections".
In the new window you can see that the "User Profile Service Application" is not selected. Since the checkbox is gray it can not even choose. To the "User Profile Service Application," and then must switch to the top "custom" and then manually select all services.



5: If one browses the portal now, the social media features already appear in the Ribbon bar. Also in the personal menu Mysiteappears for selection. This is now created with the first click, just as expected.