Пример #1
0
        static public AdamUser GetAdamUser(string tenantName, string username)
        {
            string email;

            byte[] sid;
            if (AdamConfigurationHelper.AdamManager.GetUserInfo(tenantName, username, out email, out sid))
            {
                AdamUser user = new AdamUser();
                user.PrincipleName = (new Upn(tenantName, username)).ToString();
                user.Email         = email;
                user.Sid           = sid;
                return(user);
            }
            return(null);
        }
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            string tenantName;
            string tenantUsername;

            if (!Upn.TryParse(username, out tenantName, out tenantUsername))
            {
                throw new ArgumentException(string.Format("The username {0} is invalid!", username));
            }
            AdamUser adamUser = AuthenticationProxy.GetAdamUser(tenantName, tenantUsername);

            if (adamUser == null)
            {
                return(null);
            }
            object providerUserKey = new SecurityIdentifier(adamUser.Sid, 0);

            return(new ActiveDirectoryMembershipUser(this.Name, adamUser.PrincipleName, providerUserKey, adamUser.Email, string.Empty, string.Empty
                                                     , true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now));
        }