public static string getBrManagerFromAD(string ou)
{
using (HostingEnvironment.Impersonate())
{
string ouReplace = "";
if (ou.Contains("-"))
{
ouReplace = ou.Split('-')[0].Split(' ')[0];
}
string managerName = "";
try
{
List<Principal> allUsers = new List<Principal>();
// create your domain context and define the OU container to search in
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "ABC.LOCAL",
"OU=Users," + "OU=" + ouReplace + ",OU=Branch Offices,DC=ABC,DC=Local");
// define a "query-by-example" principal - here, we search for a UserPrincipal (user)
UserPrincipal qbeUser = new UserPrincipal(ctx);
// create your principal searcher passing in the QBE principal
PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
// find all matches
foreach (var found in srch.FindAll())
{
// do whatever here - "found" is of type "Principal" - it could be user, group, computer.....
allUsers.Add(found);
}
foreach (Principal user in allUsers)
{
if (!string.IsNullOrEmpty(user.DistinguishedName))
{
DirectoryEntry dex = new DirectoryEntry("LDAP://" + user.DistinguishedName);
if (dex != null)
{
if (dex.Properties["title"].Count > 0)
{
if ((string)dex.Properties["title"].Value == "Manager")
{
managerName = (string)dex.Properties["displayName"].Value;
}
}
}
}
}
}
catch (Exception e)
{
Logging.SaveErrorLogData(e.Message, "getBrManagerFromAD");
}
return managerName;
}
}
Monday, December 19, 2016
Sunday, December 18, 2016
How to Hide Sharepoint Cog (Gear)
1. On SharePoint Designer Choose the relevant Master Page
2. Then Search for "<SharePoint:SiteActions"
3. Paste Visible="false" after LargeIconMode="false"
2. Then Search for "<SharePoint:SiteActions"
3. Paste Visible="false" after LargeIconMode="false"
Monday, February 15, 2016
Give Proper permission through Run SPSecurity.RunWithElevatedPrivileges
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite site = SPContext.Current.Site;
SPWeb web = SPContext.Current.Web;
using (SPSite newSite = new SPSite(site.ID))
{
using (SPWeb newWeb = newSite.OpenWeb(web.ID))
{
foreach (SPGroup group in newWeb.Groups)
{
foreach (SPUser u in group.Users)
{
if (SPContext.Current.Web.CurrentUser.Name == u.Name)
{
SPQuery depquery = new SPQuery();
depquery.Query = "<Where><Contains><FieldRef Name='Title' /><Value Type='Text'>" + group.Name + "</Value></Contains></Where>";
SPListItemCollection item = SPContext.Current.Web.Lists[Constants.HNBDepartmentList()].GetItems(depquery);
if (item.Count > 0)
{
grpName = group.Name;
}
}
}
}
}
}
});
{
SPSite site = SPContext.Current.Site;
SPWeb web = SPContext.Current.Web;
using (SPSite newSite = new SPSite(site.ID))
{
using (SPWeb newWeb = newSite.OpenWeb(web.ID))
{
foreach (SPGroup group in newWeb.Groups)
{
foreach (SPUser u in group.Users)
{
if (SPContext.Current.Web.CurrentUser.Name == u.Name)
{
SPQuery depquery = new SPQuery();
depquery.Query = "<Where><Contains><FieldRef Name='Title' /><Value Type='Text'>" + group.Name + "</Value></Contains></Where>";
SPListItemCollection item = SPContext.Current.Web.Lists[Constants.HNBDepartmentList()].GetItems(depquery);
if (item.Count > 0)
{
grpName = group.Name;
}
}
}
}
}
}
});
Sunday, February 7, 2016
User Profile Syncronisation Service "Starting" Fixed
http://myspexp.com/2011/04/28/user-profile-synchronization-servicehangs-on-starting-i-fixed-it/
Monday, February 1, 2016
Adding and Install .wsp to a Site Collection using Powershell Commands
Stsadm
To Add : stsadm –o addsolution –name SharePointProject2.wsp
To Install : stsadm –o deploysolution –name SharePointProject2.wsp –url http://moss-server –allowCasPolicies –immediate
To Upgrade : stsadm –o upgradesolution –name SharePointProject2.wsp –filename SharePointProject2.wsp –immediate –allowCasPolicies
PowerShell
To Add : Add-SPSolution c:\code\SharePointProject2\bin\debug\SharePointProject2.wsp
To Install : Install-SPSolution –Identity SharePointProject2.wsp –WebApplication http://sp2010 -GACDeployment
To Update : Update-SPSolution –Identity SharePointProject2.wsp –LiteralPath c:\code\SharePointProject2\bin\debug\SharePointProject2.wsp –GACDeployment
To Uninstall : Uninstall-SPSolution –Identity SharePointProject2.wsp –WebApplication http://sp2010
To Remove : Remove-SPSolution –Identity SharePointProject2.wsp
Wednesday, January 27, 2016
Service Account Setup for Sharepoint 2013
Account name
|
Role
|
Domain rights
|
Local SharePoint Server rights needed
|
SQL rights needed
|
sp_install
|
Used to install SharePoint binaries.
|
Domain User
|
Local administrator on all SharePoint boxes
|
public, dbcreator, and securityadmin SQL roles. Need to be SysAdmin on SQL when installing the Workflow Manager
|
sp_farm
|
Farm account. Used for Windows Timer Service, Central Admin and User Profile service
|
Domain User
|
Local Admin during UPS provisioning, log on locally right
|
None
|
sp_webapp
|
App pool id for content web apps
|
Domain User
|
None
|
None
|
sp_serviceapps
|
Service app pool id
|
Domain User
|
None
|
None
|
sp_content
|
Default account used by Search Service Application to crawl content
|
Domain User
|
None
|
None
|
sp_userprofile1
|
Account used by the User Profile services to access Active Directory
|
Must have Replicating Change permissions to AD. Must be given in BOTH ADUC and ADSIEDIT. If domain is Windows 2003 or early, must also be a member of the "Pre-Windows 2000" built-in group.
|
None
|
None
|
sp_superuser2
|
Cache account
|
Domain User
|
Web application Policy Full Control
Web application super account setting
|
None
|
sp_superreader2
|
Cache account
|
Domain User
|
Web application Policy Full read
Web application super reader account setting
|
None
|
sqlinstall | Account SQL is installed with | Domain User | None | Local Administrator on the SQL box |
sqluser | Account the SQL Instance is running as. | Domain User | None | Will be given necessary permissions when SQL Server is installed by a local administrator on the SQL box |
Tuesday, January 26, 2016
Installing Workflow With Service Bus 1.0
http://sharepoint-community.net/profiles/blogs/configuring-sharepoint-2013-to-support-workflow-management
Thursday, January 21, 2016
Installing Sharepoint prerequisits with powershell
Import-Module ServerManager
Copy-Item -Path "$($ENV:SystemRoot)\System32\ServerManager.exe" `
-Destination "$($ENV:SystemRoot)\System32\ServerManagerCmd.exe" -Force
Add-WindowsFeature NET-WCF-HTTP-Activation45,NET-WCF-TCP-Activation45,NET-WCF-Pipe-Activation45
Add-WindowsFeature Net-Framework-Features,Web-Server,Web-WebServer, `
Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing, `
Web-Http-Errors,Web-App-Dev,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext, `
Web-ISAPI-Filter,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor, `
Web-Http-Tracing,Web-Security,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering, `
Web-Digest-Auth,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression, `
Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Application-Server, `
AS-Web-Support,AS-TCP-Port-Sharing,AS-WAS-Support, AS-HTTP-Activation, `
AS-TCP-Activation,AS-Named-Pipes,AS-Net-Framework,WAS,WAS-Process-Model, `
WAS-NET-Environment,WAS-Config-APIs,Web-Lgcy-Scripting,Windows-Identity-Foundation, `
Server-Media-Foundation,Xps-Viewer
Restart-Computer
- See more at:
http://www.someshinyobject.com/posts/server-2012-r2-and-sharepoint-2013-the-tool-was-unable-to-install-application-server-role-web#sthash.GUyPViJ3.dpuf
- See more at:
http://www.someshinyobject.com/posts/server-2012-r2-and-sharepoint-2013-the-tool-was-unable-to-install-application-server-role-web#sthash.GUyPViJ3.dpuf
Copy-Item -Path "$($ENV:SystemRoot)\System32\ServerManager.exe" `
-Destination "$($ENV:SystemRoot)\System32\ServerManagerCmd.exe" -Force
Add-WindowsFeature NET-WCF-HTTP-Activation45,NET-WCF-TCP-Activation45,NET-WCF-Pipe-Activation45
Add-WindowsFeature Net-Framework-Features,Web-Server,Web-WebServer, `
Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing, `
Web-Http-Errors,Web-App-Dev,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext, `
Web-ISAPI-Filter,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor, `
Web-Http-Tracing,Web-Security,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering, `
Web-Digest-Auth,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression, `
Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Application-Server, `
AS-Web-Support,AS-TCP-Port-Sharing,AS-WAS-Support, AS-HTTP-Activation, `
AS-TCP-Activation,AS-Named-Pipes,AS-Net-Framework,WAS,WAS-Process-Model, `
WAS-NET-Environment,WAS-Config-APIs,Web-Lgcy-Scripting,Windows-Identity-Foundation, `
Server-Media-Foundation,Xps-Viewer
Restart-Computer
Import
-Module
ServerManager
Copy-Item
-Path
"$($ENV:SystemRoot)\System32\ServerManager.exe"
`
-Destination
"$($ENV:SystemRoot)\System32\ServerManagerCmd.exe"
-Force
Add
-WindowsFeature
NET
-WCF
-HTTP
-Activation45,NET
-WCF
-TCP
-Activation45,NET
-WCF
-Pipe
-Activation45
Add
-WindowsFeature
Net
-Framework
-Features
,Web
-Server
,Web
-WebServer
, `
Web
-Common
-Http
,Web
-Static
-Content
,Web
-Default
-Doc
,Web
-Dir
-Browsing
, `
Web
-Http
-Errors
,Web
-App
-Dev
,Web
-Asp
-Net
,Web
-Net
-Ext
,Web
-ISAPI
-Ext
, `
Web
-ISAPI
-Filter
,Web
-Health
,Web
-Http
-Logging
,Web
-Log
-Libraries
,Web
-Request
-Monitor
, `
Web
-Http
-Tracing
,Web
-Security
,Web
-Basic
-Auth
,Web
-Windows
-Auth
,Web
-Filtering
, `
Web
-Digest
-Auth
,Web
-Performance
,Web
-Stat
-Compression
,Web
-Dyn
-Compression
, `
Web
-Mgmt
-Tools
,Web
-Mgmt
-Console
,Web
-Mgmt
-Compat
,Web
-Metabase
,Application
-Server
, `
AS
-Web
-Support
,AS
-TCP
-Port
-Sharing
,AS
-WAS
-Support
, AS
-HTTP
-Activation
, `
AS
-TCP
-Activation
,AS
-Named
-Pipes
,AS
-Net
-Framework
,WAS,WAS
-Process
-Model
, `
WAS
-NET
-Environment
,WAS
-Config
-APIs
,Web
-Lgcy
-Scripting
,Windows
-Identity
-Foundation
, `
Server
-Media
-Foundation
,Xps
-Viewer
Restart
-Computer
Import
-Module
ServerManager
Copy-Item
-Path
"$($ENV:SystemRoot)\System32\ServerManager.exe"
`
-Destination
"$($ENV:SystemRoot)\System32\ServerManagerCmd.exe"
-Force
Add
-WindowsFeature
NET
-WCF
-HTTP
-Activation45,NET
-WCF
-TCP
-Activation45,NET
-WCF
-Pipe
-Activation45
Add
-WindowsFeature
Net
-Framework
-Features
,Web
-Server
,Web
-WebServer
, `
Web
-Common
-Http
,Web
-Static
-Content
,Web
-Default
-Doc
,Web
-Dir
-Browsing
, `
Web
-Http
-Errors
,Web
-App
-Dev
,Web
-Asp
-Net
,Web
-Net
-Ext
,Web
-ISAPI
-Ext
, `
Web
-ISAPI
-Filter
,Web
-Health
,Web
-Http
-Logging
,Web
-Log
-Libraries
,Web
-Request
-Monitor
, `
Web
-Http
-Tracing
,Web
-Security
,Web
-Basic
-Auth
,Web
-Windows
-Auth
,Web
-Filtering
, `
Web
-Digest
-Auth
,Web
-Performance
,Web
-Stat
-Compression
,Web
-Dyn
-Compression
, `
Web
-Mgmt
-Tools
,Web
-Mgmt
-Console
,Web
-Mgmt
-Compat
,Web
-Metabase
,Application
-Server
, `
AS
-Web
-Support
,AS
-TCP
-Port
-Sharing
,AS
-WAS
-Support
, AS
-HTTP
-Activation
, `
AS
-TCP
-Activation
,AS
-Named
-Pipes
,AS
-Net
-Framework
,WAS,WAS
-Process
-Model
, `
WAS
-NET
-Environment
,WAS
-Config
-APIs
,Web
-Lgcy
-Scripting
,Windows
-Identity
-Foundation
, `
Server
-Media
-Foundation
,Xps
-Viewer
Restart
-Computer
Subscribe to:
Posts (Atom)