How can I get the outlook address book group members in order to check if they exists in our system.
I have to create a plugin that will do following things:
For example we have a group 'Test Group' and there are 'Member 1, Member 2, Member 3'. How can I check if those members exist already as contacts in the CRM.
If the Member 1 doesn't exists we will add him to CRM contacts.
I've trying this but i get group and principalGroup = null. Could you please explain why?
I've tried to get all groups for current user and the group I've needed wasn't there.
var allGroups = new GroupPrincipal(principalContext, "*");
PrincipalSearcher ps = new PrincipalSearcher(allGroups);
It seem that there aren't any group from outlook address book.
Does anyone know the reason?
private void GetUsers()
{
using (var principalContext = new PrincipalContext(ContextType.Domain))
{
var users = getAllExistingUsers();
foreach (var user in users.Entities)
{
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext, IdentityType.SamAccountName, login);
if (userPrincipal != null)
{
var groupPrincipal = GroupPrincipal.FindByIdentity(principalContext, IdentityType.Name, "Test Group");
DirectoryEntry de = userPrincipal.GetUnderlyingObject() as DirectoryEntry;
var groups = de.Properties["memberof"].Value;
}
}
}
using (var group = GroupPrincipal.FindByIdentity(principalContext,IdentityType.Name, "Test Group"))
{
if (group != null)
{
foreach(Principal p in group.GetMembers())
{
var userId = p.Guid;
}
}
}
}
}
*This post is locked for comments