예제 #1
0
파일: CEUtil.cs 프로젝트: paulsm4/CEQuery
        private CEUtil(string ceUri, string osName, string ceUser, string password, LogMsg logMsg)
        {
#if (P8_451)
            // P8 4.5 authentication
            UsernameToken token = new UsernameToken(ceUser, password, PasswordOption.SendPlainText);
            UserContext.SetProcessSecurityToken(token);
#else
            // P8 5.0 authentication
            UsernameCredentials cred = new UsernameCredentials(ceUser, password);
            ClientContext.SetProcessCredentials(cred);
#endif
            conn = Factory.Connection.GetConnection(ceUri);
            isCredentialsEstablished = true;

            // Get domain name
            PropertyFilter pf = new PropertyFilter();
            pf.AddIncludeProperty(0, null, null, "Name", null);
            pf.AddIncludeProperty(0, null, null, "Id", null);
            domain = Factory.Domain.FetchInstance(conn, null, null);
            objStore = Factory.ObjectStore.FetchInstance(domain, osName, null);

            // Successfully initialized CEUtil object: save singleton instance
            this.logMsg = logMsg;
            gCEUtil = this;
        }