public static bool SyncVirtualUserFromAD(string adPath, string username, User virtualUser, List <PropertyMapping> propertyMappings, string customADAdminAccountName, string customADAdminAccountPwd, bool novellSupport, string guidProp, bool syncUserName)
{
bool success = false;
try
{
using (var serverEntry = ConnectToAD(adPath, customADAdminAccountName, customADAdminAccountPwd, novellSupport, guidProp))
{
var filter = string.Format("({0}={1})", SyncConfiguration.GetUserNameProp(propertyMappings), username);
using (var entry = SearchADObject(serverEntry, filter, novellSupport, guidProp))
{
if (entry != null)
{
UpdatePortalUserCustomProperties(entry, virtualUser, propertyMappings, syncUserName);
var guid = Common.GetADObjectGuid(entry, guidProp);
if (guid.HasValue)
{
virtualUser["SyncGuid"] = ((Guid)guid).ToString();
success = true;
}
}
}
}
}
catch (Exception ex)
{
AdLog.LogException(ex);
}
return(success);
}