Thursday, December 19, 2013

SharePoint 2010 How to hide the recycle bin and the all site content links

SharePoint 2010 How to hide the recycle bin and the all site content links




1. Edit page
2. Add content editor webpart (CEWebpart)
3. Edit webpart from its dropdown menu
4. Select Editor and select HTML source
5. Past it
--------------------------------------
<style type="text/css">
.s4-recentchanges {
DISPLAY: none
}
.s4-specialNavLinkList {
DISPLAY: none
}</style>
-----------------------------------------------

 n save
6. Select layout 's of CEWebpart and Select Direction as none.
7. click ok.

Wednesday, December 18, 2013

Show current Page location, Breadcrumb global navigation, Show parent sites

                     Show current Page location, 

                    Breadcrumb global navigation,

                                 Show parent sites.


Replace below code in v4.Master:
Before it take its backup and make it Check-Out and modify for safety.
Note: If you its needed, for each site you need to to be repeated.

-----------------------------------------------------------------------------------------
<asp:ContentPlaceHolder id="PlaceHolderSiteName" runat="server">
<SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" id="onetidProjectPropertyTitle">
<SharePoint:ProjectProperty Property="Title" runat="server" />
</SharePoint:SPLinkButton>
</asp:ContentPlaceHolder>

-------------------------------------------WITH--------------------------------------------------------

<asp:SiteMapPath
     runat="server"
     SiteMapProviders="SPSiteMapProvider,SPXmlContentMapProvider"
     RenderCurrentNodeAsLink="false"
     NodeStyle-CssClass="breadcrumbNode"
     CurrentNodeStyle-CssClass="breadcrumbCurrentNode"
     RootNodeStyle-CssClass="breadcrumbRootNode"
     HideInteriorRootNodes="true"
     SkipLinkText=""/>

Thursday, December 12, 2013

Create URL in Site actions menu

Create URL in Site actions menu


<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
        Id="MyAction"
        GroupId="SiteActions"
        Location="Microsoft.SharePoint.StandardMenu"
        Sequence="2000"
        Title="RKU App Page"
        Description="Custom page by RKU">
<UrlAction Url="_layouts/TestJAVA/rku.aspx" />
</CustomAction>
</Elements>

Friday, September 6, 2013

Javascript Popup

string script = "<script language='javascript'>alert('Fields are Empty')</script>";
      Page.ClientScript.RegisterClientScriptBlock(GetType(), "Register", script);

Wednesday, July 3, 2013

Get All Sites in a SharePoint form


Get All Sites in a SharePoint form

            SPFarm farm = SPFarm.Local;
            SPWebService service = farm.Services.GetValue<SPWebService>("");
            foreach (SPWebApplication webapp in service.WebApplications)
            {
                foreach (SPSite site in webapp.Sites)
                {                
                    foreach (SPWeb web in site.AllWebs)
                    {
                        Console.WriteLine(web.Url);                       
                    }
                }
            }

Tuesday, July 2, 2013

SharePoint Site Accessed users list

SharePoint Site Accessed users list



 foreach (SPWeb web in siteCol.AllWebs)
                                {                                   
                                    DataTable dtUsers = new DataTable();
                                    dtUsers = web.GetUsageData(SPUsageReportType.user, SPUsagePeriodType.lastMonth, 400, DateTime.Now);
                                    if (dtUsers != null)
                                    {
                                        foreach (DataRow rows in dtUsers.Rows)
                                        {
                                            Allrecords.Add(rows["User"] + "|" + rows["Most Recent Day"] + "|" + web.Url);
                                            //Most Recent Day
                                            // Console.WriteLine(rows["User"] + "|" + rows["Most Recent Day"]);
                                        }
                                        foreach (DataColumn col in dtUsers.Columns)
                                        {
                                            Console.WriteLine(col.ColumnName);
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine(web.Url);
                                    }
                                    
                                }

Monday, July 1, 2013

Get active directory user details c#, (Get All Active directory domains in a Network & All Enabled users from Active Directory) to CSV

Get All Active directory domains in a Network .

ArrayList Doamin = new ArrayList();
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                Forest currentForest = Forest.GetCurrentForest();
                DomainCollection domains = currentForest.Domains;
                foreach (Domain objDomain in domains)
                {
                    Doamin.Add(objDomain.Name);
                              
                }    
            });




===========================see more code==============================

All Enabled users from AD.

public static void GetAllInactivePersonsNEm()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate
            {               
                //StreamWriter SW;
                //SW = File.AppendText("C:\\ADall_InactivePrsns_NEm.csv");
                //SW.WriteLine("User Name, Email , Domain Directory");
                Forest currentForest = Forest.GetCurrentForest();
                DomainCollection domains = currentForest.Domains;
                try
                {
                    foreach (Domain objDomain in domains)
                    {
                        Console.WriteLine("---Domain--" + objDomain.Name + "------");

                        string lDAPName = "LDAP://" + objDomain.Name;
                        DirectoryEntry entry = new DirectoryEntry("LDAP://" + objDomain.Name);
                        DirectorySearcher Dsearch = new DirectorySearcher(entry);

                        Dsearch.Filter = "(&(objectClass=user)(objectCategory=Person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))";
                        try
                        {
                            foreach (SearchResult sResultSet in Dsearch.FindAll())
                            {
                                DirectoryEntry de = sResultSet.GetDirectoryEntry();
                                Console.WriteLine(GetProperty(sResultSet, "cn"));

                                //String ObjEmail = (GetProperty(sResultSet, "mail"));
                                //if (!String.IsNullOrEmpty(ObjEmail))
                                //{
                                   // SW.WriteLine(GetProperty(sResultSet, "cn").Replace(",", " ") + "," + GetProperty(sResultSet, "mail") + "," + entry.Path.ToString());
                                //}
                            }
                        }
                        catch (Exception ex)
                        {

                        }
                    }
                }
                catch (Exception ex)
                {
                }
               // SW.Close();
                Console.WriteLine("AD aAtive Document Write Completed..4..");               
                Console.ReadLine();
            });
        }


        public static string GetProperty(SearchResult searchResult, string PropertyName)
        {
            if (searchResult.Properties.Contains(PropertyName))
            {
                return searchResult.Properties[PropertyName][0].ToString();
            }
            else
            {
                return string.Empty;
            }
        }