Hey All,
I have successfully coded to get the information from our AD Domain but because of the mergers we have many trusted domains and the users needs to be verified against them as well. But I really don't know how its been done in C#. I know it can be done because the Sharepoint 2003 finds any user across the company without making any changes. So, I assume there is a easy way to do the search in trusted domains when the user is not found on the local/default domain.
Any one has any sample code to do that please?
My current code is as follows:
public void GetUserInfo(String sDomainUserID)
{
String sUserID = GetUserID(sDomainUserID);
String sFilter = "(&(sAMAccountname=" + sUserID + ")(objectClass=user))";
string sDomain = "LDAP://" + WebConfigurationManager.AppSettings["domain"];
DirectoryEntry DirEntry = new DirectoryEntry(sDomain.Trim());
DirEntry.AuthenticationType = AuthenticationTypes.Secure;
DirectorySearcher DirSearcher = new DirectorySearcher(DirEntry);
DirSearcher.Filter = sFilter;
SearchResult Result = DirSearcher.FindOne();
DirectoryEntry GetDirEntry = Result.GetDirectoryEntry();
foreach (string propertyName in Result.Properties.PropertyNames)
{
foreach (object sItem in Result.Properties[propertyName])
{
switch (propertyName)
{
case "name":
string[] UserName = ((string)sItem).Split(new Char[] { ',' });
sFName = UserName[1].Trim();
sLName = UserName[0].Trim();
break;
case "streetaddress":
sAddress = GetPropertyValue(sItem).Replace("\r\n", " ");
break;
case "l":
sCity = GetPropertyValue(sItem);
break;
case "postalcode":
sZip = GetPropertyValue(sItem);
break;
case "title":
sTitle = GetPropertyValue(sItem);
break;
case "company":
sCompany = GetPropertyValue(sItem);
break;
case "extensionattribute2":
sRCCode = GetPropertyValue(sItem);
break;
case "extensionattribute1":
sUID = GetPropertyValue(sItem);
break;
case "mail":
sEMail = GetPropertyValue(sItem);
break;
case "info":
sIPager = GetPropertyValue(sItem).Replace("ipager: ", "");
break;
case "extensionattribute11":
if (GetPropertyValue(sItem) == "BlackBerryUser")
{ boolBBUser = true; }
else
{ boolBBUser = false; }
break;
case "extensionattribute5":
sEmpType = GetPropertyValue(sItem);
break;
case "department":
sDept = GetPropertyValue(sItem);
break;
case "telephonenumber":
sPhone = GetPropertyValue(sItem);
break;
case "st":
sState = GetPropertyValue(sItem);
break;
case "extensionattribute13":
sATTUID = GetPropertyValue(sItem);
break;
case "extensionattribute3":
sGLC = GetPropertyValue(sItem);
break;
case "extensionattribute4":
sCUID = GetPropertyValue(sItem);
break;
case "manager":
DirectoryEntry de = new DirectoryEntry("LDAP://" + sItem.ToString());
sSupUID = GetPropertyValue(de.Properties["samaccountname"].Value);
sSupEMail = GetPropertyValue(de.Properties["mail"].Value);
sSupiPager = GetPropertyValue(de.Properties["info"].Value).Replace("ipager: ", "");
sSupPhone = GetPropertyValue(de.Properties["telephonenumber"].Value);
break;
}
}
}
}
I would greatly appreciate if anyone could help me out in this matter.
thanks,
vincent