J
jgfreitas
Hi Experts...
Anyone could help me?
I´m getting this error when I try to create a new contact object on
AD / Exchange using special characters on Common Name:
{"There is a naming violation." }
{System.Runtime.InteropServices.COMException}
_COMPlusExceptionCode: -532459699
_HResult: -2147016649
_message: There is a naming violation.
Source: System.DirectoryServices
The code I´m using is below:
public void CriarContact
(string accountBusca, string fullName, string firstName,
string lastName,
string initials, string displayName, string ag, string
mail, string company, string telephoneNumber,
string country, string state, string city, string manager,
string notes, string alias, string ou
)
{
try
{
DirectoryEntry de = null;
if(!ou.Equals(String.Empty))
{
string path = Entry.Path.Substring(0,
Entry.Path.ToUpper().IndexOf("DC=")) + ou;
DirectoryEntry deOU = new
DirectoryEntry(path);
de = deOU.Children.Add("CN=" +
accountBusca, "Contact");
}
else
{
de = Entry.Children.Add("CN=" +
accountBusca, "Contact");
}
de.Properties["displayName"].Add(displayName);
de.Properties["givenName"].Add(firstName);
de.Properties["sn"].Add(lastName);
de.Properties["initials"].Add(initials);
if (!mail.Trim().Equals(string.Empty))
de.Properties["mail"].Add(mail);
if (!alias.Trim().Equals(string.Empty))
de.Properties["mailNickName"].Add(alias);
DirectoryEntry deManager =
ObterUsuarioPorAccount(manager);
de.Properties["manager"].Add(deManager.Properties["distinguishedName"].Value.ToString());
de.Properties["info"].Add(notes);
IMailRecipient oMB =
(IMailRecipient)de.NativeObject;
oMB.AutoGenerateEmailAddresses = false;
oMB.Alias = accountBusca;
oMB.SMTPEmail = mail;
de.Properties["TargetAddress"].Add("SMTP: " +
mail);
de.CommitChanges();
de.Close();
}
Is this possible? (to use special characters on the common name of the
object)
I found this Microsoft article about this subject, but the server
where I´m running the app is Win 2003... so I can't apply the
hotfix...
http://support.microsoft.com/kb/834541/en-us
I would appreciate any help...
Tnks
Juliana
Anyone could help me?
I´m getting this error when I try to create a new contact object on
AD / Exchange using special characters on Common Name:
{"There is a naming violation." }
{System.Runtime.InteropServices.COMException}
_COMPlusExceptionCode: -532459699
_HResult: -2147016649
_message: There is a naming violation.
Source: System.DirectoryServices
The code I´m using is below:
public void CriarContact
(string accountBusca, string fullName, string firstName,
string lastName,
string initials, string displayName, string ag, string
mail, string company, string telephoneNumber,
string country, string state, string city, string manager,
string notes, string alias, string ou
)
{
try
{
DirectoryEntry de = null;
if(!ou.Equals(String.Empty))
{
string path = Entry.Path.Substring(0,
Entry.Path.ToUpper().IndexOf("DC=")) + ou;
DirectoryEntry deOU = new
DirectoryEntry(path);
de = deOU.Children.Add("CN=" +
accountBusca, "Contact");
}
else
{
de = Entry.Children.Add("CN=" +
accountBusca, "Contact");
}
de.Properties["displayName"].Add(displayName);
de.Properties["givenName"].Add(firstName);
de.Properties["sn"].Add(lastName);
de.Properties["initials"].Add(initials);
if (!mail.Trim().Equals(string.Empty))
de.Properties["mail"].Add(mail);
if (!alias.Trim().Equals(string.Empty))
de.Properties["mailNickName"].Add(alias);
DirectoryEntry deManager =
ObterUsuarioPorAccount(manager);
de.Properties["manager"].Add(deManager.Properties["distinguishedName"].Value.ToString());
de.Properties["info"].Add(notes);
IMailRecipient oMB =
(IMailRecipient)de.NativeObject;
oMB.AutoGenerateEmailAddresses = false;
oMB.Alias = accountBusca;
oMB.SMTPEmail = mail;
de.Properties["TargetAddress"].Add("SMTP: " +
mail);
de.CommitChanges();
de.Close();
}
Is this possible? (to use special characters on the common name of the
object)
I found this Microsoft article about this subject, but the server
where I´m running the app is Win 2003... so I can't apply the
hotfix...
http://support.microsoft.com/kb/834541/en-us
I would appreciate any help...
Tnks
Juliana