Saturday, August 4, 2012

[sharepointdiscussions] Digest Number 4491

4 New Messages

Digest #4491
1a
Re: AD groups not updating on SharePoint by "shahzeb khan" shahzebkn
1b
Re: AD groups not updating on SharePoint by "Greg" gregoryj.mcallister
2a
Re: Unzipping by means of an Event receiver by "Greg" gregoryj.mcallister
2b
Re: Unzipping by means of an Event receiver by "Greg" gregoryj.mcallister

Messages

Fri Aug 3, 2012 6:38 am (PDT) . Posted by:

"shahzeb khan" shahzebkn

I am not sure but seems to me that profile service not working properly. check your profile service

To: sharepointdiscussions@yahoogroups.com
From: imstac@yahoo.com
Date: Thu, 2 Aug 2012 19:54:32 +0000
Subject: [sharepointdiscussions] AD groups not updating on SharePoint

I have a webpart in which I have assigned AD Groups to the target audience. I added a user to my AD group but they still cannot see the webpart.

Things I have tried:

User logged off and back on to computer

User rebooted

Ran gpresult command on their machine to make sure they were showing as part of the group.

Ran Full user profile sync in SharePoint

Ran stsaadm -o sync from command line (not sure what all this syncs but thought it couldn't hurt)

Did iisreset

It has been 3 days since we added the user to the group and they still cannot see the webpart. If I add an AD group to the target audience that the user was already a member of then they can see the webpart.

Any suggestions on what else I can try?



[Non-text portions of this message have been removed]

Fri Aug 3, 2012 6:50 am (PDT) . Posted by:

"Greg" gregoryj.mcallister

First - Verify that the user is showing up in the profiles and in search. That will verify that the user profiles services are working correctly. Then if that is correct proceed by removing the web part then adding it back in. I have found, in some cases, that web parts do not update just because something else has and in order to actually reconnect and get all the updates the web part needs to be fleshed back out. Just a thought.

--- In sharepointdiscussions@yahoogroups.com, "imstac" <imstac@...> wrote:
>
> I have a webpart in which I have assigned AD Groups to the target audience. I added a user to my AD group but they still cannot see the webpart.
>
> Things I have tried:
> User logged off and back on to computer
> User rebooted
> Ran gpresult command on their machine to make sure they were showing as part of the group.
> Ran Full user profile sync in SharePoint
> Ran stsaadm -o sync from command line (not sure what all this syncs but thought it couldn't hurt)
> Did iisreset
>
> It has been 3 days since we added the user to the group and they still cannot see the webpart. If I add an AD group to the target audience that the user was already a member of then they can see the webpart.
>
> Any suggestions on what else I can try?
>

Fri Aug 3, 2012 8:29 am (PDT) . Posted by:

"Greg" gregoryj.mcallister

Yes I have. The issue is not apparently the the fact that I am not doing
the Unzip part right it seems to be that the code just does not want to
run at all. Here is another example of my code and it still breaks. The
DotNetZip is almost word for word from the DotNetZip examples. When ever
I add the DotNet Portion (the using statement and down) the code drops
through it. If I comment it out then the code gets into the block. See
comments in code:

using Ionic.Zip;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.ObjectModel;
using System.IO;
using System.IO.Compression;
using System.Security.Permissions;

namespace CL.Receiver.Invoices.InvoiceZipAdded
{
/// <summary>
/// List Item Events
/// </summary>
public class InvoiceZipAdded : SPItemEventReceiver
{
/// <summary>
/// An invoice zip file was added and requires unzipping
/// </summary>
public override void ItemAdded(SPItemEventProperties properties)
{
// read properties from the item after adding to the library
base.ItemAdded(properties);
string afterURL = properties.AfterUrl;
string fileExtension =
afterURL.Substring(afterURL.LastIndexOf('.') + 1);
string fileName =
afterURL.Substring(afterURL.LastIndexOf('/') + 1);

// using local drives only until I get DotNetZip to function
ignoring the actual web file that kicks this off
// except to drive the event into the unzip process
string sourceFilePath = @"c:\windowspowershell\";
string targetFilePath = @"c:\windowspowershell\test\";
string sourceFile = sourceFilePath + fileName;

// unzip it if it is an invoice zip file and is from the
correct directory
if (fileExtension == "zip")
{
if (afterURL == "Invoices/" + fileName)
{
// code drives into this line and this line reads
correctly as
// letsUnzip("c:\\windowspowershell\\",
c:\\windowspowershell\\test\\")
// breakpoint set on next line
letsUnzip(sourceFile, targetFilePath);
// code never gets past here and there are no error
messages, it just falls through
}
}
}
public void letsUnzip(string theSource, string theTarget)
{
// program drops into here and displays the next line fine
until I uncomment the
// using line and below to actually unzip the file contents

// test line
string testFileName = theSource;

// if commented out the above line works
// if not commented out, code never gets here (breakpoint
set at 'public')
using (ZipFile zip = ZipFile.Read(theSource))
{
foreach (ZipEntry entry in zip)
{
entry.Extract(theTarget);
}
}
}
}
}

--- In sharepointdiscussions@yahoogroups.com, "onewisegeek"
<1wisegeek@...> wrote:
>
> Did you look through the examples?
>
>
http://dotnetzip.codeplex.com/wikipage?title=CS-Examples&referringTitle=\
Examples

>

[Non-text portions of this message have been removed]

Fri Aug 3, 2012 12:35 pm (PDT) . Posted by:

"Greg" gregoryj.mcallister

UPDATE: More information and hopefully the SharePoint Code Guru's can make some sense of this.

I took this code and placed it in the :

using Ionic.Zip;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DotNetZipTest
{
class Program
{
static void Main()
{
string sourceFile = @"\\\\localhost\\invoices\\testfile.zip";
string targetPath = @"\\\\localhost\\invoices\";

using (ZipFile zip = ZipFile.Read(sourceFile))
{
foreach (ZipEntry entry in zip)
{
entry.Extract(targetPath, ExtractExistingFileAction.OverwriteSilently);
}
}
}
}
}

And it ran perfectly.

I took this code:

using Ionic.Zip;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.ObjectModel;
using System.Security.Permissions;

namespace CL.Receiver.Invoices.InvoiceZipAdded
{
/// <summary>
/// List Item Events
/// </summary>
public class InvoiceZipAdded : SPItemEventReceiver
{
/// <summary>
/// An invoice zip file was added and requires unzipping
/// </summary>
public override void ItemAdded(SPItemEventProperties properties)
{
// read properties from the item after adding to the library
base.ItemAdded(properties);
string afterURL = properties.AfterUrl;
string fileExtension = afterURL.Substring(afterURL.LastIndexOf('.') + 1);
string fileName = afterURL.Substring(afterURL.LastIndexOf('/') + 1);

// using UNC reference because I wrote a console app that uses the using block shown below and UNC references to the same file testing here
string sourceFilePath = @"\\\\ausnb-747218\\invoices\\";
string targetFilePath = @"\\\\ausnb-747218\\";
string sourceFile = sourceFilePath + fileName;

// unzip it if it is an invoice zip file and is from the correct directory
if (fileExtension == "zip")
{
if (afterURL == "Invoices/" + fileName)
{
// The code below works perfectly well if in a seprate console app using UNC file locations. No issues at all
// until the code is loaded here
using (ZipFile zip = ZipFile.Read(sourceFile))
{
foreach (ZipEntry entry in zip)
{
entry.Extract(targetFilePath, ExtractExistingFileAction.OverwriteSilently);
}
}
}
}
}
}
}

and it fails. If I remove everything from the using statement down, the code then runs.

My conclusion is, and this is where I need the help, is that the DotNetZip library will not run within an Event Receiver. Now this begs the question as to why?

The block of code is the same, the permissions are no different, same files, same website... just makes no sense.

All help appreciated.

No comments: