Archive for the ‘Administration’ Category

Nov
01
Filed Under (Administration, Security, Web Services) by Andy Diericks on 25-04-2007

The code below will show you how to get all the groups which a user belongs to, through webservices using JavaScript.

That functionality isn’t provided OOB in Sharepoint 2007, but can be really useful when you get a lot of security groups and some issues about them. It can be used for auditing, debugging …

Here is an example:

The user enter the account "MYDOMAIN\MyAccount" click on the link and get:

  • Group Name: Group1
  • Group Decription: Description of Group1
  • Group Name:Group2
  • Group Decription:Description of Group2

 

Implementation

For doing it, I will use a JavaScript library, which is in fact a proxy class, which means that our code will be easier to write, maintain and debug, all the boring stuff are already done for you ;-)

Here is the link to the site of Darren which contain the library in the Download section. http://darrenjohnstone.net

Here is some examples http://darrenjohnstone.net/2008/07/22/examples-for-the-sharepoint-and-office-live-javascript-api/

To include the library in your Sharepoint site, please follow Darren’s advices:

If you have full control of your server:

1) Locate the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS folder.
2) In there create a new folder called JSAPI.
3) Place the extracted .js files in there.

If you don’t have full access:

1) Open SharePoint Designer and connect to your site.
2) Create a new folder called JSAPI at the root of the site.
3) Copy the extracted .js files to the folder by dragging them from Windows Explorer to SP Designer.

Where to put code ?

  • In a html file, and show it in a page viewer webpart or
  • Insert it in a page layout, or even master page.

 

Coding

First of all, you will need to make some include to be able to use the web proxy class:

   1: <script type="text/javascript" src="/_layouts/JSAPI/SPAPI_Core.js"></script>
   2: <script type="text/javascript" src="/_layouts/JSAPI/SPAPI_Lists.js"></script>
   3: <script type="text/javascript" src="/_layouts/JSAPI/SPAPI_UserGroup.js"></script>

 

We need to create a simple form, containing

  • A textbox: the user will type the username(with domain) in it.
  • A link: to start the job.
   1: <form method="post" action="">
   2: <input id="Text1" type="text" />
   3: <a href='#' onclick="javascript:start()">Start the search</a>
   4: </form>
   5: <div id="username_div"></div>    

 

And now the interesting part, I will shortly explain the JavaScript methods below:

  • Start: We get the user name from a textbox and call the getGroupCollection and Formatresult methods.
  • getGroupCollection: Receive the username by parameter. The method will use a SPAPI_UserGroup object and request the groups that the users belongs to, through the getGroupCollectionFromUser method. The result will be put in two arrays, the first containing the names of the groups, the second one containing the descriptions.
  • FormatResult: The arrays containing the groups names and descriptions are  parsed. The content is formatted in a more friendly way.

 

   1: <script type="text/javascript" language="javascript">    
   2:  
   3: function getGroupCollection(userName)
   4: {
   5:     var groupName = new Array();
   6:     var groupDescription = new Array();
   7:     var arrGroup = new Array(groupName,groupDescription);
   8:     
   9:     var userGroup = new SPAPI_UserGroup('');
  10:     var groupItems = userGroup.getGroupCollectionFromUser(userName)
  11:     
  12:     if (groupItems.status == 200)
  13:     {
  14:             var groupTags = groupItems.responseXML.getElementsByTagName('Group');
  15:     
  16:             for(var i=0;i<groupTags.length;i++)
  17:             {
  18:                 groupName.push(groupTags[i].getAttribute("Name"));        
  19:                 groupDescription.push(groupTags[i].getAttribute("Description"));        
  20:             }
  21:     }
  22:     return arrGroup;
  23: }
  24:  
  25: function formatResult(groups,username)
  26: {
  27:     var result=""; 
  28:     result = "The user " + username + " belongs to: </br>";
  29:     for(var i=0;i<groups.length;i++)
  30:     {        
  31:         result+= "<b>Group name: </b>" + groups[0][i] + "<br />";                       
  32:         result+= "<b>Group Description: </b>" + groups[1][i] + "<br /> <p> </p>";
  33:     }
  34:  
  35: return result;
  36: }
  37:  
  38: function start()
  39: {
  40:     var userName = document.getElementById('Text1').value;
  41:     var groups = getGroupCollection(userName);
  42:     document.getElementById('username_div').innerHTML = formatResult(groups,userName);     
  43:     
  44: }
  45: </script>            

 

If you have questions, please ask them!



Aug
15
Filed Under (Administration, Reports, Sites) by Andy Diericks on 25-04-2007

You can configure the Site Directory at two level:

  • Portal
  • Central Administration

Of course the configuration on the Central Admin will override those at the level portal.

I think it’s more logical to configure it at portal level and don’t touch it at Central admin level for one reason :

In the real world you will have 2 teams or roles, the sytem admins and the content managers, and that tool will be more needed to manage the portal content, for example they will be able to track all sites created during a content migration or creation process.

The Site Directory can be customize to add person to contact for each site or creating purpose, it can be a real tool of content management.

By the way every project is different so maybe in your case it will be better to configure it at central Admin level.

Don’t hesitate to explain me your point of view.

Configuration at portal level

Go to « Site Actions » -> « Site Settings » and in “Site Collection Administration” part choose the “Site directory settings” options.

site collection administration

You can specify the path to the “Site directory” and choose “Enforce listing new sites in Site Directory”, as described, when you will create a new site on the portal it will be automatically be listed in the site directory.

site directory settings

Configuration at Central Admin level

To configure it go to the “Central Administration” -> “Operations” -> “Site directory Settings”.You will have the same configuration as in the portal level.

Central administration - site directory settings

In the “Central Administration” -> “Operations” -> “Site directory links scan”.

Here you will be able to define vhich view you want to scan, and if the site list have to be automatically updated.

Site directory links scan

Configuration of the scan using STSADM

Referring to the MOSS help, some STSADM commands about the scheduling of the scan:

To view the scheduling of the scan job:

   1: stsadm –o getsitedirectoryscanschedule

 

To schedule the scan:

   1: stsadm -o setsitedirectoryscanschedule -schedule <recurrence string>

 

The recurrence string indicates the frequency or the date and time at which to run the job. Examples include:

“every 5 minutes between 0 and 59″

“hourly between 0 and 59″

“daily at 15:00:00″

“weekly between Fri 22:00:00 and Sun 06:00:00″

“monthly at 15 15:00:00″

“yearly at Jan 1 15:00:00″