Hi Everybody,
I wrote the code to search a group as follows:
....
directorySearcher.Filter = "(&(objectClass=group)(sAMAccountName=" + ReplaceSpecialCharInAD(groupName) + "))";
.....
public string ReplaceSpecialCharInAD(string strSource)
{
string str = "";
str = strSource;
str = str.Replace(@"\", @"\5C");
str = str.Replace(@";", @"\5C\3B");
str = str.Replace("*", @"\2A");
str = str.Replace("\"", @"\5C\22");
str = str.Replace("(", @"\28");
str = str.Replace(")", @"\29");
str = str.Replace(" NUL ", @" \00 ");
str = str.Replace("/", @"\2F");
return str;
}
If I create a group in AD without special characters, it always
worked fine but if I create a group with special characters (example: Group 2 /
5 ~!@#$%^&*(() _ +) it does not always find this group even exists in the
domain.
Any ideas on how to work around this? Please help me.
Thanks,
Aladin