How can i differentiate the userid if same userid is available in two different OU within same domai

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi All,
I am using ADFS ,Active Directory and asp.net based relying party application.
In my active directory structure there are two OU (customer and CustomerSupport). I am creating a user in customer OU through C# code and using UPN field as user logon name. And Creating same UserId from backend in customerSupport OU.
Now I am using below code in my relying party application for retrieving <span>
the user from OU’s.
<span style="font-family:Courier New; color:blue; font-size:10pt public<span style="font-family:Courier New; font-size:10pt
<span style="color:blue static <span style="color:blue string GetADPath(<span style="color:blue string userType)
<span style="font-family:Courier New; font-size:10pt <span>
{
<span style="font-family:Courier New; font-size:10pt
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue if (_logger.IsDebugEnabled)
<span style="font-family:Courier New; font-size:10pt <span>
_logger.Debug(<span style="color:#a31515 "ADHelper:Enter GetADPath");
<span style="font-family:Courier New; font-size:10pt
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:green // Local variables
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue string adPath = <span style="color:blue string.Empty;
<span style="font-family:Courier New; font-size:10pt
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue try
<span style="font-family:Courier New; font-size:10pt <span>
{
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue if (userType.Equals(Constants.UserType.Customer))
<span style="font-family:Courier New; font-size:10pt <span>
adPath = Utility.GetConfigSetting(Constants.AppSettings.CustomersOUPath);
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue else <span style="color:blue if (userType.Equals(Constants.UserType.CustomerSupport))
<span style="font-family:Courier New; font-size:10pt <span>
adPath = Utility.GetConfigSetting(Constants.AppSettings.CustomersSupportOUPath);
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue if (_logger.IsDebugEnabled)
<span style="font-family:Courier New; font-size:10pt <span>
_logger.Debug(<span style="color:#a31515 "ADHelper:Exit GetADPath");
<span style="font-family:Courier New; font-size:10pt
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue return adPath;
<span style="font-family:Courier New; font-size:10pt <span>
}
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue catch (<span style="color:#2b91af ApplicationException appex)
<span style="font-family:Courier New; font-size:10pt <span>
{
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue if (_logger.IsErrorEnabled)
<span style="font-family:Courier New; font-size:10pt <span>
_logger.Error(<span style="color:#a31515 "ADHelper:Exception occurred in GetADPath. Message: ", appex);
<span style="font-family:Courier New; font-size:10pt
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue throw appex;
<span style="font-family:Courier New; font-size:10pt <span>
}
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue catch (<span style="color:#2b91af Exception ex)
<span style="font-family:Courier New; font-size:10pt <span>
{
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue if (_logger.IsErrorEnabled)
<span style="font-family:Courier New; font-size:10pt <span>
<span> _logger.Error(<span style="color:#a31515 "ADHelper:Exception occurred in GetADPath. Message: ", ex);
<span style="font-family:Courier New; font-size:10pt
<span style="font-family:Courier New; font-size:10pt <span>
<span style="color:blue throw ex;
<span style="font-family:Courier New; font-size:10pt <span>
}
<span style="font-family:Courier New; font-size:10pt <span>
}
Now my problem is if the same user-Id and password is created on both OU’s. Then CustomerSupport OU user never get login in relying party application its throw rights error.Even I have provided all admin rights in the CustomerSupport OU user’s.
But each time my application check Customer OU’s user (normal user) and user can login other application as normal user.
When I changed the password of CustomerSupport OU user’s then it’s throw “ invalid Id password error”.And user never login in the Relying Party application.
Please any one can suggest how can I handle this situation.
Thanks in Advance.

View the full article
 
Back
Top