コード例 #1
0
        /*
         * When I first made this method it ran correctly but I received an error message about access. as seen below
         * Logged User prxwstl1hesc cannot create in ou = people,ou = OFA,ou = Government,o = ny,c = us because user is not in OU scope of DA
         *
         * Since this is a HESC account I will make a HESC user but i now need to find out the ou for that.  Since we make these apps for other people there might need to be a master level id we use or each agency specific work we do should have their own id
         *
         */
        public void AddUser()
        {
            dsmlQueryService client = new dsmlQueryService();

            client.Url         = "https://qadaws.svc.ny.gov/daws/services/dsmlSoapQuery";
            client.Credentials = new NetworkCredential("prxwsTL1HESC", "sfvwRMnB7N");

            AddRequest[] addRequest = new AddRequest[1] {
                new AddRequest()
            };
            addRequest[0].dn = "ou = people,ou =NYS Department of Higher Education Services Corporation,ou = Government,o = ny,c = us";
            DsmlAttr[] attributesToAdd = new DsmlAttr[11];
            attributesToAdd[0] = new DsmlAttr()
            {
                name = "dn", value = new String[] { "ou = people,ou =NYS Department of Higher Education Services Corporation,ou = Government,o = ny,c = us" }
            };
            attributesToAdd[1] = new DsmlAttr()
            {
                name = "sn", value = new String[] { "Jordan" }
            };
            attributesToAdd[2] = new DsmlAttr()
            {
                name = "uid", value = new String[] { "MontyJordanEBSTest001" }
            };
            attributesToAdd[3] = new DsmlAttr()
            {
                name = "givenname", value = new String[] { "Monty" }
            };
            attributesToAdd[4] = new DsmlAttr()
            {
                name = "mail", value = new String[] { "*****@*****.**" }
            };
            attributesToAdd[5] = new DsmlAttr()
            {
                name = "userpassword", value = new String[] { "uzRpa$$w0Rd" }
            };
            attributesToAdd[6] = new DsmlAttr()
            {
                name = "nyaccttl", value = new String[] { "1" }
            };
            attributesToAdd[7] = new DsmlAttr()
            {
                name = "nyaccttlidsource1", value = new String[] { "n/a" }
            };
            attributesToAdd[8] = new DsmlAttr()
            {
                name = "nyaccttlidsource2", value = new String[] { "n/a" }
            };
            attributesToAdd[9] = new DsmlAttr()
            {
                name = "nyaccttlivmethod", value = new String[] { "n/a" }
            };
            attributesToAdd[10] = new DsmlAttr()
            {
                name = "vetted", value = new String[] { "n/a" }
            };

            //attributesToAdd[9] = new DsmlAttr() { name = "", value = new String[] { "" } };

            addRequest[0].attr = attributesToAdd;
            BatchRequest batchRequest = new BatchRequest();

            batchRequest.addRequest = addRequest;
            BatchResponse batchResponse = client.directoryRequest(batchRequest);

            if (batchResponse != null)
            {
                LDAPResult[]    ldapResult    = batchResponse.addResponse;
                ErrorResponse[] errorResponse = batchResponse.errorResponse;

                if (errorResponse != null)
                {
                    for (int i = 0; i < errorResponse.Length; i++)
                    {
                        System.Diagnostics.Debug.WriteLine(errorResponse[i].message);
                    }
                }
            }
        }
コード例 #2
0
        public directoryRequestResponse AddUser()
        {
            System.Diagnostics.Debug.WriteLine("Going to add a user with the service reference proxy");
            //fiddler
            GlobalProxySelection.Select = new WebProxy("127.0.0.1", 8888);

            dsmlSoapClient           client       = new dsmlSoapClient();
            directoryRequestRequest  mainRequest  = new directoryRequestRequest();
            directoryRequestResponse mainResponse = new directoryRequestResponse();
            BatchRequest             batchRequest = new BatchRequest();
            AddRequest addRequest = new AddRequest();

            client.ClientCredentials.UserName.UserName = "******";
            client.ClientCredentials.UserName.Password = "******";
            AddRequest[] aReqs = new AddRequest[1];
            aReqs[0]                 = addRequest;
            batchRequest.Items       = aReqs;
            mainRequest.batchRequest = batchRequest;

            addRequest.dn = "ou=People,ou=NYS Office of Information Technology Services,ou=Government,o=ny,c=us";


            DsmlAttr[] attributesToAdd = new DsmlAttr[11];
            attributesToAdd[0] = new DsmlAttr()
            {
                name = "dn", value = new String[] { "ou=People,ou=NYS Office of Information Technology Services,ou=Government,o=ny,c=us" }
            };
            attributesToAdd[1] = new DsmlAttr()
            {
                name = "sn", value = new String[] { "Jordan" }
            };
            attributesToAdd[2] = new DsmlAttr()
            {
                name = "uid", value = new String[] { "MontyJordanEBSTest001" }
            };
            attributesToAdd[3] = new DsmlAttr()
            {
                name = "givenname", value = new String[] { "Monty" }
            };
            attributesToAdd[4] = new DsmlAttr()
            {
                name = "mail", value = new String[] { "*****@*****.**" }
            };
            attributesToAdd[5] = new DsmlAttr()
            {
                name = "userpassword", value = new String[] { "uzRpa$$w0Rd" }
            };
            attributesToAdd[6] = new DsmlAttr()
            {
                name = "nyaccttl", value = new String[] { "1" }
            };
            attributesToAdd[7] = new DsmlAttr()
            {
                name = "nyaccttlidsource1", value = new String[] { "n/a" }
            };
            attributesToAdd[8] = new DsmlAttr()
            {
                name = "nyaccttlidsource2", value = new String[] { "n/a" }
            };
            attributesToAdd[9] = new DsmlAttr()
            {
                name = "nyaccttlivmethod", value = new String[] { "n/a" }
            };
            attributesToAdd[10] = new DsmlAttr()
            {
                name = "vetted", value = new String[] { "n/a" }
            };

            addRequest.attr = attributesToAdd;

            try
            {
                mainResponse = client.directoryRequest(mainRequest);
                System.Diagnostics.Debug.WriteLine("Response: " + mainResponse);
                //The error handling changed from a web reference to a service reference.  guess the wsdl is more generic than i thought.
                ErrorResponse[] eResponses    = null;
                BatchResponse   bResponse     = mainResponse.batchResponse;
                Object[]        responseItems = bResponse.Items;
                if (responseItems != null)
                {
                    if (responseItems[0] is ErrorResponse)
                    {
                        ErrorResponse eResponse = (ErrorResponse)responseItems[0];
                        System.Diagnostics.Debug.WriteLine(eResponse.message);
                        System.Diagnostics.Debug.WriteLine(eResponse.detail);
                        System.Diagnostics.Debug.WriteLine(eResponse.type);
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Hooray no errors on response from adding a user");
                    }
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Dang it: " + e);
            }
            return(mainResponse);
        }