I'm trying to retrieve the manager email base on a user.
I did investigated about this, and I found this code but getting "Object not set to an instance", I do not know what do I need to initialize.
If someone can give me a hint. I appreciate it.
    public string GetEmail(string userId)
    {
        PrincipalContext ctx = new PrincipalContext(ContextType.Domain, null, MyDomain);
        UserPrincipal user = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, userId);
        return user.EmailAddress;
    }