Exemple #1
0
        public UserTO loginActiveDirectory(string domain, string username, string password)
        {
            UserTO result = new UserTO();

            if (String.IsNullOrEmpty(domain) || String.IsNullOrEmpty(username) || String.IsNullOrEmpty(password))
            {
                result.fault = new FaultTO("Must supply domain, username and password");
            }

            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                DataSource src = new DataSource()
                {
                    SiteId = new SiteId("1"), Modality = "FEDUID", Protocol = "LDAP", Provider = domain
                };
                AbstractDaoFactory f   = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(src.Protocol));
                LdapConnection     cxn = new LdapConnection(src);
                cxn.Account = new LdapAccount(cxn);

                LdapCredentials creds = new LdapCredentials()
                {
                    AccountName = username, AccountPassword = password
                };

                using (new Impersonator(mySession.MdwsConfiguration.LdapConfiguration.RunasUser))
                {
                    string guid = cxn.Account.authenticate(creds);

                    LdapUserDao  dao = new LdapUserDao(cxn);
                    IList <User> guidLookupResult = dao.userLookupList(new KeyValuePair <string, string>("", guid));

                    if (guidLookupResult.Count != 1)
                    {
                        throw new ApplicationException("Unexpected error - more than one user returned for authenticated user's GUID");
                    }

                    return(new UserTO(guidLookupResult[0]));
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return(result);
        }
Exemple #2
0
        //public UserTO updateActiveDirectoryProfile(string domain, string username, string password, string title,
        //    string officePhone, string faxNumber, string addressLine1, string addressLine2, string addressLine2,
        //    string city, string state, string zip, string office,

        public UserArray ldapUserLookup(string uid, string domainSearchRoot)
        {
            UserArray result = new UserArray();

            if (String.IsNullOrEmpty(uid))
            {
                result.fault = new FaultTO("Must supply domain, username and password");
            }

            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                DataSource src = new DataSource()
                {
                    SiteId = new SiteId("1"), Modality = "FEDUID", Protocol = "LDAP", Provider = "GC://dc=va,dc=gov"
                };
                if (!String.IsNullOrEmpty(domainSearchRoot))
                {
                    src.Provider = domainSearchRoot;
                }
                AbstractDaoFactory f   = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(src.Protocol));
                LdapConnection     cxn = new LdapConnection(src);
                cxn.Account = new LdapAccount(cxn);

                LdapUserDao dao = new LdapUserDao(cxn);

                IList <User> users = null;
                using (new Impersonator(mySession.MdwsConfiguration.LdapConfiguration.RunasUser))
                {
                    users = dao.userLookupList(new KeyValuePair <String, String>("", uid));
                }

                result = new UserArray(users);
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return(result);
        }