Tuesday, June 18, 2013

Infopath 2010: Get groups from user

I just want to check if a user is part of a specific group. Well, that should be simple, right? I'm using SharePoint 2010, got an Active Directory Server somewhere and InfoPath 2010. All Users are working with authenticated accounts on their clients and have authenticated users while browsing SharePoint 2010. It should really be simple, right? I mean, come on! It's all Microsoft and all connected. Right?


The short version is: I ended up coding this little thing in C#:

PrincipalContext domain = new PrincipalContext(ContextType.Domain);
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(domain, User.UserName);

// set field "isMemberTxt" to "true"
string group = "YOURADGROUP";
GroupPrincipal groupPrincipal = GroupPrincipal.FindByIdentity(domain, group);
bool isMember = userPrincipal.IsMemberOf(groupPrincipal);

if (isMember == true)
xnMyForm.SelectSingleNode("/my:myFields/my:isMemberTxt", ns).SetValue("true");
catch (Exception ex)

This will check if the current user is a member of the group "YOURADGROUP" and it will also set the field "isMemberTxt" to true. IT worked for me, but it is not ideal, I you are searching for a no-code-solution like I do. But it's something!

So if I find a no-code-solution, I will post it here.

Friday, June 7, 2013

SharePoint 2010: Flush BLOB cache

Recently I needed to flush the BLOB cache. But how should I do that? Simple, just use the script below.
$WebApp = Get-SPWebApplication "WEBAPPNAME"
Write-Host "Flushed for WebApp:" $WebApp
After that, you flushed the BLOB cache.