I am using the Active directory Core methods to first get the manager of the user by using the ADUser_Search by username and then to get the manager details using the ADUser_Get with the distinguished name. I got the results from the first method but for some users once trying to get the manager details by the ADUser_Get I am getting an exception (referral was returned from the server).
Usually, that error occurs when the information is not found under the DC you're querying. This may have to do with the connection you're using.
Try creating a connection with a broader scope so that you can query the entire domain tree of your AD.
Thanks @Renato Pauleta for your response which I understood but I am wondering why not just return an error message "not found" or something instead of taking much time and after that an exception which is very slow and leads to timeout in my app.
I switched to using the ADUser_Search with distinguished name instead of the ADUser_Get as it does not contain this strange behavior.
That's really weird. I'll need to double check.