Пример #1
0
        public DirectoryContext(ContextType ct, string name, string userName, string password)
        {
            PrincipalContext pc     = new PrincipalContext(ct, name, userName, password);
            WindowsIdentity  pident = WindowsIdentity.GetCurrent();

            this.Process = new ProcessPrincipal(pc, pident);
        }
Пример #2
0
        public DirectoryContext()
        {
            //populate process principal information
            WindowsIdentity  pident = WindowsIdentity.GetCurrent();
            PrincipalContext pc     = null;

            try {
                pc = new PrincipalContext(ContextType.Domain);
            } catch {
                pc = new PrincipalContext(ContextType.Machine);
            }
            this.Process = new ProcessPrincipal(pc, pident);
        }