Programming, SharePoint, Web

SOLVED: Redirect a SharePoint page using a meta tag to a new URL

I have a SharePoint tenant where we are working to redirect some existing pages over to landing pages that are providing instructions for migrating. Needed something short and sweet to flip it over without much trouble. It’s easier to manage with a meta rather than fighting the “making your external client side javascript work with SharePoint” fight. This one takes less than 5 minutes.

So via SharePoint Designer:

<meta http-equiv="refresh" content="0;url=http://your-url-goes-here" />

That’s it. Onto the next one!

API, Box, C#, Certificates, Web, XML

How To Use the Box API To Adjust User Properties and Make Read-Only in Bulk (w/example)

  • Get up to date on the APIs you need for users @ https://developer.box.com/v2.0/reference
  • Sign up for your developer account at your enterprise @ https://yourenterprise.app.box.com/developers/console (replace with your enterprise application name in the link above)
  • Create your Box app & API Key – link here and here
  • Pull down the Box Windows SDK @ – https://github.com/box/box-windows-sdk-v2
  • Update the pem file with your actual pem information from the app you created
    • in case you’re wondering it should contain the —–BEGIN ENCRYPTED PRIVATE KEY—– and —–END ENCRYPTED PRIVATE KEY—–
  • Update the properties appropriately in the app.config
  <appSettings>
    <add key="boxClientId" value="uniquestringhere" />
    <add key="boxClientSecret" value="uniquestringheretoo" />
    <add key="boxEnterpriseId" value="1234567" />
    <add key="boxPrivateKeyPassword" value="uniquestringhereforpassword" />
    <add key="boxPublicKeyId" value="uniquepublickeyid" />
    <add key="ClientSettingsProvider.ServiceUri" value="useifneeded" />
  </appSettings>
  • From there you can update your Main runner in the program.cs appropriately. In the case of my sample below I am getting authorized, retrieving my users and looping through everyone but the main admin account and making them read-only. I’m also writing the information out to a file so I’ll have the logs of who was set / not set.
 
            var privateKey = File.ReadAllText("private_key.pem");

            var boxConfig = new BoxConfig(CLIENT_ID, CLIENT_SECRET, ENTERPRISE_ID, privateKey, JWT_PRIVATE_KEY_PASSWORD, JWT_PUBLIC_KEY_ID);
            var boxJWT = new BoxJWTAuth(boxConfig);

            var adminToken = boxJWT.AdminToken();
            Console.WriteLine("Admin Token: " + adminToken);
            Console.WriteLine();

            var adminClient = boxJWT.AdminClient(adminToken);

            var items = await adminClient.UsersManager.GetEnterpriseUsersAsync("", 0, 1000);
            items.Entries.ForEach(async i =>
            {
                if (i.Login != "myspecialadminaccount@domain.com")
                {
                    BoxUserRequest userRequest = new BoxUserRequest()
                    {
                        Id = i.Id,
                        Status = "cannot_delete_edit_upload"
                    };
                    System.Console.WriteLine("\t{0}", i.Name);
                    System.Console.WriteLine("\t{0}", i.Id);
                    System.Console.WriteLine("\t{0}", i.Login);
                    System.Console.WriteLine("\t{0}", i.Type);
                    System.Console.WriteLine(" ");
                    // Turn on for prod
                    BoxUser user = await adminClient.UsersManager.UpdateUserInformationAsync(userRequest);
                    Console.WriteLine(userRequest.Name + "updated to read-only");
                    System.Threading.Thread.Sleep(2000);
                    stringtext = i.Name.ToString() + " - " + i.Id.ToString() + " - " + i.Login.ToString() + " - " + i.Type.ToString() + " - updated to readonly" + Environment.NewLine;
                    System.Console.WriteLine(" ");
                    
                }
                else
                {
                    BoxUserRequest userRequest = new BoxUserRequest()
                    {
                        Id = i.Id
                    };
                    System.Console.WriteLine("\t{0}", i.Name);
                    System.Console.WriteLine("\t{0}", i.Id);
                    System.Console.WriteLine("\t{0}", i.Login);
                    System.Console.WriteLine("\t{0}", i.Type);
                    System.Console.WriteLine(" ");
                    Console.WriteLine(userRequest.Name + " NOT updated to read-only");
                    System.Threading.Thread.Sleep(2000);
                    stringtext = i.Name.ToString() + " - " + i.Id.ToString() + " - " + i.Login.ToString() + " - " + i.Type.ToString() + " - NOT updated to readonly" + Environment.NewLine;
                    System.Console.WriteLine(" ");
                    
                }
            });
            File.AppendAllText("C:\\Temp\\" + "log.txt", stringtext);
  • Enable your box application to your enterprise accounts – link here
  • Run your app (In TEST with test accounts! Then, with approval, prod.)
    • If the app won’t run…check:
      • code syntax errors
      • certificate pem
      • values in the app config
      • authorization status in the admin Console on Box
      • that your app is enabled and still available on the enterprise developer site

Hope this helps! I can send the source out on request if needed (just let me know).

.Net, HTML, IIS, Sitecore, Visual Studio, Web, XML

Sitecore Error (SOLVED): An item name cannot contain any of the following characters: \/:?”\-|[] (controlled by the setting InvalidItemNameChars)

You may have ran into an issue during deployments when trying to publish in the past where you have seen this message:

“An item name cannot contain any of the following characters: \/:?”<>\-|[] (controlled by the setting InvalidItemNameChars)”

In order to help move forward on this you need to disable the default ItemNameValidation settings if you are having some deployment issues.

To do that (would only recommend temporarily) you can follow the steps below:

Add a config file to App_Config/Include named z.DisableItemNameValidation.config and put this in it:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting name="ItemNameValidation">
        <patch:attribute name="value"></patch:attribute>
      </setting>
    </settings>
  </sitecore>
</configuration>

Again, when you are finished I would recommend taking this back out of your files to keep things as standard as possible.

Blog, Web

Action board: What words and actions are driving you?

I find each day has its challenges to give a chance to reveal a new possible action that can be taken to improve the moment.

As something I am learning each day I find that sometimes it’s good to visualize key actions and values to remember how we focus ourselves and work to apply them every day. You may not apply them all at once but as you come back to it and think through your experiences you can reflect and continue to figure out where you can grow and build your partnerships.

Challenge yourself, chances are you may find you have a lot more of these than you think. Thanks for reading.

Any other good ones for the board?

Blog, Web

Four Lessons about Facing Adversity as a New Employee

When I first set out to write this I was not sure where it was going to end up. I just knew that the experiences that I have had through the years just could not be brushed off without someone gaining a valuable lesson from someone else’s story. That’s what I hope this does and I believe that if you will apply these things to your own life you will grow as a person and in your career to move forward.

So the backstory: 6 months into a new job. I now have just enough time under my belt not to be the “new guy” and enough wins and deployments to have an opinion that matters amongst the team…well, most of the team. There were a couple holdouts that simply could not believe a new guy out of school could pick up some things so quickly and be acclimated to the norm. As I sat in a traditional project staff meeting I volunteered to participate in an upcoming project of great complexity to do some development that had not been done before at that time. No sooner than I had signed myself up one of my colleagues emphatically challenged me by saying, “Just because you think you can do one or two really easy things doesn’t make you a senior analyst nor qualifies you to work on high priority projects”. I still can remember the hush in the room that day. I quickly reacted and followed that with, “Well, I understand your opinion but would like the chance to participate and to prove my abilities and will hope to show you that I can be a contributor to the project”.

So what did I learn from this experience?

Four Lessons about Facing Adversity as a new Employee:

1) In any new job or responsibility you will be challeneged on your capability. This is expected and should be welcomed as an opportunity for you to show how you can contribute with your strengths and abilities.

2) When you are challenged by others about your abilities you need to respond with your willingness to step up to the challenge. Being challenged does not mean you should run away from adversity. Strive forward to be the first in line to say, “Yes, I want to be a part of change”

3) Mistakes are often made when people get too deep into the weeds when arguing in the details of things to prove their knowledge; remember that everyone in the room has to grow in their understanding and will fail and make mistakes as well. Be patient and remember it is about the working relationship and the details.

4) Showing your resolve will allow others to see a resounding confidence and ability to accept diversity and capability to move forward. The greater you continue to build your confidence the greater you will build relationships and trust with your business and colleagues. 

So the moral of this story? In the end I not only took the additional responsibility on this project but eventually became the lead over it. As a result of its success I received a raise, a promotion and other opportunities with other projects that I would have been passed over on previously (had I backed down from the previous adversity I received). Most notably I am happy to say that out of that experience it help me to grow to respect and work well with the colleague who challenged me.

Remember to continue to believe in your confidence, trust your abilities, build the relationships with others and you will begin to see results start working greater for your good.

More to come, hope this was helpful.