I am facing a problem in my web application in the log in Page in ASP.net.The Problem is arising whenever i am authenticating my log in credentials using the LDAP to connect to Active directory in the server.I am giving you the code where the exception is getting thrown.
public string[] GetIssuerFromActiveDirectory(string loginName)
{
try
{
string[] issuerDetails = new string[3];
string path = ConfigurationManager.AppSettings["LDAPPath"];
string groupName = null;
String dn;
DirectoryEntry entry = new DirectoryEntry(path);
// Bind to the native AdsObject to force authentication.
Object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + loginName + ")";
SearchResult result = search.FindOne();
issuerDetails[0] = (String)result.Properties["name"][0];
issuerDetails[2] = (String)result.Properties["mail"][0];
int propertyCount = result.Properties["memberOf"].Count;
int equalsIndex, commaIndex;
if (propertyCount <= 0)
issuerDetails[1] = null;
else
{
for (int propertyCounter = 0; propertyCounter < propertyCount; propertyCounter++)
{
dn = (String)result.Properties["memberOf"][propertyCounter];
equalsIndex = dn.IndexOf("=", 1);
commaIndex = dn.IndexOf(",", 1);
groupName = (dn.Substring((equalsIndex + 1), (commaIndex - equalsIndex) - 1));
if (groupName.Equals(ConfigurationManager.AppSettings["AdminRole"]) || groupName.Equals(ConfigurationManager.AppSettings["MemberRole"]))
{
issuerDetails[1] = groupName;
}
}
}
return issuerDetails;
}
catch (CustomException cex)
{
throw cex;
}
catch (Exception ex)
{
Exceptions.LogException(ex);
CustomException cex = Exceptions.GetCustomException("issuer not present in active directory", ex);
throw cex;
}
}
its giving the exception at
Object obj = entry.NativeObject;
saying refferal was sent to the server.
Can anyone help me with this exception.
!--removed tag-->
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).