SHAREPOINT (2016, 2013, 2010, 2007, 2003), ASP.NET, C#, SQL, SSRS, SSAS, BI, SAP-BO, Angular JS, CSS 3, HTML 5, Aspire 2.0
Friday, June 13, 2008
Customized Theme in MOSS 2007
Customized Theme in MOSS 2007
Windows Sharepoint Server (WSS) and Sharepoint Portal Server (SPS) both ship with several built-in themes, giving you the ability to change the look and feel of a site quite dramatically. Choosing one of these themes is simply a matter of clicking on the “Site Settings” link in the upper navigation and then “Site Theme” under the “look and Feel” header. On the “Site Theme” page you should see a list of available themes on the right. Click on one of these themes and you’ll see a preview on the left of the page. All of the themes available for use on a SharePoint server are stored beneath a single folder named “THEMES“. This folder contains a unique folder for each theme: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES.
To create a theme, start by creating a new folder with the images and CSS files that make up the theme. Here are the steps to create a new theme called “MOSSTHEME″:
Here is a short procedure of creating a custom site theme named "MossTheme":
1. Copy any theme folder in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES" folder and paste with its name replaced with "MossTheme". In this example, copy GRANITE folder.
2. In MossTheme folder, rename GRANITE.INF file to MOSSTHEME.INF in upper case.
3. Open MOSSTHEME.INF file with notepad.
4. Change the value of title under [Info] to MossTheme.
5. Replace every word, Granite, under [titles] with MossTheme.
6. Open "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\SPTHEMES.XML" file with notepad.
7. Add the following lines under tag:
'<' templates '>'
'<'templateid'>'MossTheme '<'/templateid'>'
'<'displayname'>'MossTheme '<'/displayname'>'
'<'description'>'ossTheme '<'/description'>'
'<'thumbnail'>'images/ MossTheme.gif'<'/thumbnail'>'
'<'preview'>'images/ MossTheme.gif'<'/preview'>'
''
Notice that preview and thumbnail paths are images/MossTheme.gif. By default, MOSS 2007 and WSS 3.0 will not have such image files.
8. In order to display thumbnail and preview correctly, you will need to capture the screen and save the file in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES" folder with MossTheme.gif name. You can change the .gif file name if you change the thumbnail and preview file names in tag.
9. Do an iisrest for the server to recognize the new theme.
Pretty simple procedure. Now you are ready to test your new theme. In Site Settings, you can now choose MOSSTHEME; however, the theme will not differ from Granite theme. Now, it is time for you to play with theme.css file!
Posted by Karun at Wednesday, May 07, 2008
Windows Sharepoint Server (WSS) and Sharepoint Portal Server (SPS) both ship with several built-in themes, giving you the ability to change the look and feel of a site quite dramatically. Choosing one of these themes is simply a matter of clicking on the “Site Settings” link in the upper navigation and then “Site Theme” under the “look and Feel” header. On the “Site Theme” page you should see a list of available themes on the right. Click on one of these themes and you’ll see a preview on the left of the page. All of the themes available for use on a SharePoint server are stored beneath a single folder named “THEMES“. This folder contains a unique folder for each theme: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES.
To create a theme, start by creating a new folder with the images and CSS files that make up the theme. Here are the steps to create a new theme called “MOSSTHEME″:
Here is a short procedure of creating a custom site theme named "MossTheme":
1. Copy any theme folder in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES" folder and paste with its name replaced with "MossTheme". In this example, copy GRANITE folder.
2. In MossTheme folder, rename GRANITE.INF file to MOSSTHEME.INF in upper case.
3. Open MOSSTHEME.INF file with notepad.
4. Change the value of title under [Info] to MossTheme.
5. Replace every word, Granite, under [titles] with MossTheme.
6. Open "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\SPTHEMES.XML" file with notepad.
7. Add the following lines under tag:
'<' templates '>'
'<'templateid'>'MossTheme '<'/templateid'>'
'<'displayname'>'MossTheme '<'/displayname'>'
'<'description'>'ossTheme '<'/description'>'
'<'thumbnail'>'images/ MossTheme.gif'<'/thumbnail'>'
'<'preview'>'images/ MossTheme.gif'<'/preview'>'
''
Notice that preview and thumbnail paths are images/MossTheme.gif. By default, MOSS 2007 and WSS 3.0 will not have such image files.
8. In order to display thumbnail and preview correctly, you will need to capture the screen and save the file in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES" folder with MossTheme.gif name. You can change the .gif file name if you change the thumbnail and preview file names in tag.
9. Do an iisrest for the server to recognize the new theme.
Pretty simple procedure. Now you are ready to test your new theme. In Site Settings, you can now choose MOSSTHEME; however, the theme will not differ from Granite theme. Now, it is time for you to play with theme.css file!
Posted by Karun at Wednesday, May 07, 2008
Thursday, June 12, 2008
How to change a user's password in Active Directory with Directory Services and C#
How to change a user's password in Active Directory with Directory Services and C#
How to change a user's password in Active Directory with Directory Services and C#
Below is a code snippet that I hope will be helpful. There are some obvious assumptions made - that the user has experience coding in Directory Services and C# - let me know if you would like more info.
private const string GETUSERID_QUERY = "((&(objectClass=user)(samAccountName={0}))(&(objectClass=contact)(displayName={0})))";
public bool ChangePassword(string rootDSE, string userName, string newPassword) { // Here, the rootDSE is already set, so is the user's name and their desired new password. // We'll call a sub that will resolve the user's name to their ID in AD and invoke the change password on that userID // You can do something as simple as DirectoryEntry root = new DirectoryEntry() - that'll return your root to you... // User name is the same as Context.User.Identity.Name - their loginID (please forgive any typoes - I'm not using a dev env for this)...
using(DirectoryEntry userEntry = GetUserByLoginID(root, username)) { try { userEntry.Invoke("SetPassword", new object[] { newPassword }); userEntry.Invoke("SetInfo"); // It's possible you might not even need this call...
userEntry.CommitChanges();
} catch(System.Reflection.TargetInvocationException err) { throw new PasswordPolicyException(comError.Message,comError); /// Assuming you have a method to handle this... } } }
private DirectoryEntry GetUserByLoginID(string rootDSE, string userID) { using (DirectoryEntry searchRoot = new DirectoryEntry(rootDSE)) { using (DirectorySearcher searcher = new DirectorySearcher(searchRoot, String.Format(GETUSERID_QUERY, userID))) { SearchResult searchResult = searcher.FindOne(); if (searchResult==null) return null; else return searchResult.GetDirectoryEntry(); } } }
How to change a user's password in Active Directory with Directory Services and C#
Below is a code snippet that I hope will be helpful. There are some obvious assumptions made - that the user has experience coding in Directory Services and C# - let me know if you would like more info.
private const string GETUSERID_QUERY = "((&(objectClass=user)(samAccountName={0}))(&(objectClass=contact)(displayName={0})))";
public bool ChangePassword(string rootDSE, string userName, string newPassword) { // Here, the rootDSE is already set, so is the user's name and their desired new password. // We'll call a sub that will resolve the user's name to their ID in AD and invoke the change password on that userID // You can do something as simple as DirectoryEntry root = new DirectoryEntry() - that'll return your root to you... // User name is the same as Context.User.Identity.Name - their loginID (please forgive any typoes - I'm not using a dev env for this)...
using(DirectoryEntry userEntry = GetUserByLoginID(root, username)) { try { userEntry.Invoke("SetPassword", new object[] { newPassword }); userEntry.Invoke("SetInfo"); // It's possible you might not even need this call...
userEntry.CommitChanges();
} catch(System.Reflection.TargetInvocationException err) { throw new PasswordPolicyException(comError.Message,comError); /// Assuming you have a method to handle this... } } }
private DirectoryEntry GetUserByLoginID(string rootDSE, string userID) { using (DirectoryEntry searchRoot = new DirectoryEntry(rootDSE)) { using (DirectorySearcher searcher = new DirectorySearcher(searchRoot, String.Format(GETUSERID_QUERY, userID))) { SearchResult searchResult = searcher.FindOne(); if (searchResult==null) return null; else return searchResult.GetDirectoryEntry(); } } }
Create a Custom Theme for WSS 3.0 or MOSS 2007
Create a Custom Theme for WSS 3.0 or MOSS 2007
SharePoint Out-of-Box Themes
If the blue and white default theme for SharePoint does not fit your style, you can choose another theme in WSS 3.0 or MOSS 2007. SharePoint provides 18 themes out of the box.
To change the theme of a site
1. Select Site Settings under Site Actions
2. Click on Site Theme under Look and Feel
3. On the Site Theme page, you can select different themes and you’ll see a preview of that theme on the left. Once you have decided on a theme, click the Apply button.
Viola! Your site now has a new look and feel.
Create a Custom Theme to apply But what if you don’t want to use an out of the box theme? Create your own!! To create a custom theme for applying to sites, you need to re-purpose an existing theme. It’s quite easy with a few modifications. If you can copy/paste, you can do it!
Step 1 – Copy existing theme
Choose a theme to re-purpose (something that closely resembles your desired look)
For our example, we are using “Wheat”
Choose a name for your new theme
For our example, we will use “LewTek”
Copy the chosen theme in the themes folder in 12 Hive
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES"
Paste this folder and rename it to your chosen new name
Step 2 – Edit Setup Information File
In your new theme folder, rename OLDNAME.INF file to NEWNAME.INF (Wheat to LewTek)
– Ensure its upper case
Open NEWNAME.INF with notepad or your favorite text editor (LEWTEK.INF)
Change the value of title under [info] from Oldname to Newname.
Change all values under [titles] from Oldname to Newname.
Step 3 – Edit SPTHEMES.XML
Next we need to edit this file so that we can actually choose our newly created theme. This will make it available in the list of themes on the Site Theme page.
Open SPTHEMES.xml in notepad or any other text editor for editing. It is located in the following directory:
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\SPTHEMES.XML"
Next you need to add your new template. Add the following lines under the tag (you may find it easier to just copy and paste the tags for an existing theme, and then changing it): LewTek LewTek Type a description for your new theme. images/thlewtek.gif images/thlewtek.gif
The thumbnail and preview tag reference an image. This image does not exist yet and you’ll need to create it. Once your theme is complete, you can take a screenshot of it and then resize it.
This will be the preview image on the Site Theme page.
Ensure that the size of the image is 375 x 231 pixels.
Once you create the image, place it in the following directory:
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES"
Now if you navigate back to the Site Theme page and refresh it – you’ll see your custom theme available to apply to the site. You’re done!
Edit Your Custom Theme
The good news is that you created a custom theme to apply to sites. The bad news? Well, it looks just like the old theme that you copied. There are many ways to edit the theme that you have created, so I won’t go into much detail on that here. However, here are some tips and resources I recommend.
Theme Editing Tips
The file theme.css in your theme folder contains all of your styles
Edit this style sheet to make changes to your theme’s look – change the colors, change the font, etc...
Images in your theme folder can be edited / replaced.
After making any changes to your theme, reset IIS prior to reapplying the theme.
The theme is stored in the database when you apply it, so you must refresh.
You reset IIS by Start > Run: iisreset
Make incremental backups of your Theme folder as you are working. Somewhere along the way you WILL mess up and need to revert.
Theme Editing Resources
MOSS CSS style reference:
http://www.heathersolomon.com/content/sp07cssreference.htm
Image Editing Software (free)
http://www.getpaint.net/index.html
Theme generator (great for consolidating colors in a style sheet)
http://hermansberghem.googlepages.com/themegenerator.htm
IE Developer Toolbar (nice tool for viewing styles on a page in real time)
http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en#Overview
Notepad2 (enhanced notepad features – good for text editing if you don’t have an editor)
http://www.flos-freeware.ch/notepad2.html
SharePoint Out-of-Box Themes
If the blue and white default theme for SharePoint does not fit your style, you can choose another theme in WSS 3.0 or MOSS 2007. SharePoint provides 18 themes out of the box.
To change the theme of a site
1. Select Site Settings under Site Actions
2. Click on Site Theme under Look and Feel
3. On the Site Theme page, you can select different themes and you’ll see a preview of that theme on the left. Once you have decided on a theme, click the Apply button.
Viola! Your site now has a new look and feel.
Create a Custom Theme to apply But what if you don’t want to use an out of the box theme? Create your own!! To create a custom theme for applying to sites, you need to re-purpose an existing theme. It’s quite easy with a few modifications. If you can copy/paste, you can do it!
Step 1 – Copy existing theme
Choose a theme to re-purpose (something that closely resembles your desired look)
For our example, we are using “Wheat”
Choose a name for your new theme
For our example, we will use “LewTek”
Copy the chosen theme in the themes folder in 12 Hive
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES"
Paste this folder and rename it to your chosen new name
Step 2 – Edit Setup Information File
In your new theme folder, rename OLDNAME.INF file to NEWNAME.INF (Wheat to LewTek)
– Ensure its upper case
Open NEWNAME.INF with notepad or your favorite text editor (LEWTEK.INF)
Change the value of title under [info] from Oldname to Newname.
Change all values under [titles] from Oldname to Newname.
Step 3 – Edit SPTHEMES.XML
Next we need to edit this file so that we can actually choose our newly created theme. This will make it available in the list of themes on the Site Theme page.
Open SPTHEMES.xml in notepad or any other text editor for editing. It is located in the following directory:
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\SPTHEMES.XML"
Next you need to add your new template. Add the following lines under the
The thumbnail and preview tag reference an image. This image does not exist yet and you’ll need to create it. Once your theme is complete, you can take a screenshot of it and then resize it.
This will be the preview image on the Site Theme page.
Ensure that the size of the image is 375 x 231 pixels.
Once you create the image, place it in the following directory:
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES"
Now if you navigate back to the Site Theme page and refresh it – you’ll see your custom theme available to apply to the site. You’re done!
Edit Your Custom Theme
The good news is that you created a custom theme to apply to sites. The bad news? Well, it looks just like the old theme that you copied. There are many ways to edit the theme that you have created, so I won’t go into much detail on that here. However, here are some tips and resources I recommend.
Theme Editing Tips
The file theme.css in your theme folder contains all of your styles
Edit this style sheet to make changes to your theme’s look – change the colors, change the font, etc...
Images in your theme folder can be edited / replaced.
After making any changes to your theme, reset IIS prior to reapplying the theme.
The theme is stored in the database when you apply it, so you must refresh.
You reset IIS by Start > Run: iisreset
Make incremental backups of your Theme folder as you are working. Somewhere along the way you WILL mess up and need to revert.
Theme Editing Resources
MOSS CSS style reference:
http://www.heathersolomon.com/content/sp07cssreference.htm
Image Editing Software (free)
http://www.getpaint.net/index.html
Theme generator (great for consolidating colors in a style sheet)
http://hermansberghem.googlepages.com/themegenerator.htm
IE Developer Toolbar (nice tool for viewing styles on a page in real time)
http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en#Overview
Notepad2 (enhanced notepad features – good for text editing if you don’t have an editor)
http://www.flos-freeware.ch/notepad2.html
Subscribe to:
Posts (Atom)