Import.Enterprise fix
This commit is contained in:
parent
25fdedd221
commit
1f5d09fbb1
2 changed files with 64 additions and 32 deletions
|
@ -164,34 +164,60 @@ namespace WebsitePanel.Import.Enterprise
|
||||||
type = null;
|
type = null;
|
||||||
email = null;
|
email = null;
|
||||||
name = (string)child.Properties["name"].Value;
|
name = (string)child.Properties["name"].Value;
|
||||||
|
|
||||||
//account type
|
//account type
|
||||||
typeProp = child.Properties["msExchRecipientDisplayType"];
|
typeProp = child.Properties["msExchRecipientDisplayType"];
|
||||||
|
|
||||||
|
int typeDetails = 0;
|
||||||
|
PropertyValueCollection typeDetailsProp = child.Properties["msExchRecipientTypeDetails"];
|
||||||
|
if (typeDetailsProp != null)
|
||||||
|
{
|
||||||
|
if (typeDetailsProp.Value != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
object adsLargeInteger = typeDetailsProp.Value;
|
||||||
|
typeDetails = (Int32)adsLargeInteger.GetType().InvokeMember("LowPart", System.Reflection.BindingFlags.GetProperty, null, adsLargeInteger, null);
|
||||||
|
}
|
||||||
|
catch { } // just skip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (child.SchemaClassName)
|
switch (child.SchemaClassName)
|
||||||
{
|
{
|
||||||
case "user":
|
case "user":
|
||||||
email = (string)child.Properties["userPrincipalName"].Value;
|
email = (string)child.Properties["userPrincipalName"].Value;
|
||||||
if (typeProp == null || typeProp.Value == null)
|
|
||||||
{
|
|
||||||
type = "User";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int mailboxType = (int)typeProp.Value;
|
|
||||||
|
|
||||||
switch (mailboxType)
|
if (typeDetails == 4)
|
||||||
{
|
{
|
||||||
case 1073741824:
|
type = "Shared Mailbox";
|
||||||
type = "User Mailbox";
|
}
|
||||||
break;
|
else
|
||||||
case 7:
|
{
|
||||||
type = "Room Mailbox";
|
|
||||||
break;
|
if (typeProp == null || typeProp.Value == null)
|
||||||
case 8:
|
{
|
||||||
type = "Equipment Mailbox";
|
type = "User";
|
||||||
break;
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
|
int mailboxType = (int)typeProp.Value;
|
||||||
|
|
||||||
|
switch (mailboxType)
|
||||||
|
{
|
||||||
|
case 1073741824:
|
||||||
|
type = "User Mailbox";
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
type = "Room Mailbox";
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
type = "Equipment Mailbox";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!string.IsNullOrEmpty(type))
|
if (!string.IsNullOrEmpty(type))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -781,12 +781,20 @@ namespace WebsitePanel.Import.Enterprise
|
||||||
}
|
}
|
||||||
int mailboxType = (int)type.Value;
|
int mailboxType = (int)type.Value;
|
||||||
|
|
||||||
PropertyValueCollection typeDetails = entry.Properties["msExchRecipientTypeDetails"];
|
|
||||||
int mailboxTypeDetails = 0;
|
int mailboxTypeDetails = 0;
|
||||||
|
PropertyValueCollection typeDetails = entry.Properties["msExchRecipientTypeDetails"];
|
||||||
if (typeDetails!=null)
|
if (typeDetails!=null)
|
||||||
{
|
{
|
||||||
if (typeDetails.Value != null)
|
if (typeDetails.Value != null)
|
||||||
mailboxTypeDetails = (int)typeDetails.Value;
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
object adsLargeInteger = typeDetails.Value;
|
||||||
|
mailboxTypeDetails = (Int32)adsLargeInteger.GetType().InvokeMember("LowPart", System.Reflection.BindingFlags.GetProperty, null, adsLargeInteger, null);
|
||||||
|
}
|
||||||
|
catch { } // just skip
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExchangeAccountType accountType = ExchangeAccountType.Undefined;
|
ExchangeAccountType accountType = ExchangeAccountType.Undefined;
|
||||||
|
@ -831,18 +839,16 @@ namespace WebsitePanel.Import.Enterprise
|
||||||
if (emailAddress.ToLower().StartsWith("smtp:"))
|
if (emailAddress.ToLower().StartsWith("smtp:"))
|
||||||
emailAddress = emailAddress.Substring(5);
|
emailAddress = emailAddress.Substring(5);
|
||||||
|
|
||||||
|
if (EmailAddressExists(emailAddress))
|
||||||
if (!emailAddress.Equals(defaultEmail, StringComparison.InvariantCultureIgnoreCase))
|
|
||||||
{
|
{
|
||||||
if (EmailAddressExists(emailAddress))
|
if ((!emailAddress.Equals(defaultEmail, StringComparison.InvariantCultureIgnoreCase)) && (!emailAddress.Equals(email, StringComparison.InvariantCultureIgnoreCase)))
|
||||||
{
|
Log.WriteInfo(string.Format("Email address {0} already exists. Skipped", emailAddress));
|
||||||
Log.WriteInfo(string.Format("Email address {0} already exists. Skipped", emailAddress));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
// register email address
|
|
||||||
Log.WriteInfo(string.Format("Importing email {0}", emailAddress));
|
|
||||||
AddAccountEmailAddress(userId, emailAddress);
|
|
||||||
}
|
}
|
||||||
|
// register email address
|
||||||
|
Log.WriteInfo(string.Format("Importing email {0}", emailAddress));
|
||||||
|
AddAccountEmailAddress(userId, emailAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.WriteEnd("User imported");
|
Log.WriteEnd("User imported");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue