예제 #1
0
        public void VmDirSafeLDAPBind(string host, string upn, string passwd)
        {
            SetVersion(LDAPOption.LDAP_VERSION);
            var VmDirError  = LdapClientLibrary.VmDirSafeLDAPBind(out this._connection, host, upn, passwd);
            var returnError = LdapError.VmDirMapLdapError((int)VmDirError);

            ErrorCheckerHelper.Validate(returnError);
        }
예제 #2
0
        internal static bool IsLdapError(LdapError error)
        {
            if (error == LdapError.IsLeaf || error == LdapError.InvalidCredentials || error == LdapError.SendTimeOut)
            {
                return(true);
            }

            return(error >= LdapError.ServerDown && error <= LdapError.ReferralLimitExceeded);
        }
예제 #3
0
        internal static bool IsLdapError(int errorCode)
        {
            LdapError error = (LdapError)NormalizeResultCode(errorCode);

            if (error == LdapError.IsLeaf || error == LdapError.InvalidCredentials || error == LdapError.SendTimeOut)
            {
                return(true);
            }

            return(error >= LdapError.ServerDown && error <= LdapError.ReferralLimitExceeded);
        }
예제 #4
0
파일: Utility.cs 프로젝트: nickchal/pash
		internal static bool IsLdapError(LdapError error)
		{
			if (error == LdapError.IsLeaf || error == LdapError.InvalidCredentials || error == LdapError.SendTimeOut)
			{
				return true;
			}
			else
			{
				if (error < LdapError.ServerDown || error > LdapError.ReferralLimitExceeded)
				{
					return false;
				}
				else
				{
					return true;
				}
			}
		}
예제 #5
0
        private void GetResultsHelper(LdapPartialAsyncResult asyncResult)
        {
            LdapConnection con          = asyncResult.con;
            IntPtr         ldapResult   = (IntPtr)0;
            IntPtr         entryMessage = (IntPtr)0;
            ResultAll      resultType   = ResultAll.LDAP_MSG_RECEIVED;

            if (asyncResult.resultStatus == ResultsStatus.CompleteResult)
            {
                resultType = ResultAll.LDAP_MSG_POLLINGALL;
            }

            try
            {
                SearchResponse response = (SearchResponse)con.ConstructResponse(asyncResult.messageID, LdapOperation.LdapSearch, resultType, asyncResult.requestTimeout, false);
                // this should only happen in the polling thread case
                if (response == null)
                {
                    // only when request time out has not yet expiered
                    if ((asyncResult.startTime.Ticks + asyncResult.requestTimeout.Ticks) > DateTime.Now.Ticks)
                    {
                        // this is expected, just the client does not have the result yet
                        return;
                    }
                    else
                    {
                        // time out, now we need to throw proper exception
                        throw new LdapException((int)LdapError.TimeOut, LdapErrorMappings.MapResultCode((int)LdapError.TimeOut));
                    }
                }

                if (asyncResult.response != null)
                {
                    AddResult(asyncResult.response, response);
                }
                else
                {
                    asyncResult.response = response;
                }

                // if search is done, set the flag
                if (response.searchDone)
                {
                    asyncResult.resultStatus = ResultsStatus.Done;
                }
            }
            catch (Exception e)
            {
                if (e is DirectoryOperationException)
                {
                    SearchResponse response = (SearchResponse)(((DirectoryOperationException)e).Response);

                    if (asyncResult.response != null)
                    {
                        AddResult(asyncResult.response, response);
                    }
                    else
                    {
                        asyncResult.response = response;
                    }

                    // set the response back to the exception so it holds all the results up to now
                    ((DirectoryOperationException)e).Response = asyncResult.response;
                }
                else if (e is LdapException)
                {
                    LdapException ldapE     = (LdapException)e;
                    LdapError     errorCode = (LdapError)ldapE.ErrorCode;

                    if (asyncResult.response != null)
                    {
                        // add previous retrieved entries if available
                        if (asyncResult.response.Entries != null)
                        {
                            for (int i = 0; i < asyncResult.response.Entries.Count; i++)
                            {
                                ldapE.results.Add(asyncResult.response.Entries[i]);
                            }
                        }

                        // add previous retrieved references if available
                        if (asyncResult.response.References != null)
                        {
                            for (int i = 0; i < asyncResult.response.References.Count; i++)
                            {
                                ldapE.results.Add(asyncResult.response.References[i]);
                            }
                        }
                    }
                }

                // exception occurs, this operation is done.
                asyncResult.exception    = e;
                asyncResult.resultStatus = ResultsStatus.Done;

                // need to abandon this request
                Wldap32.ldap_abandon(con.ldapHandle, asyncResult.messageID);
            }
        }
 internal static bool IsLdapError(LdapError error)
 {
     return ((((error == LdapError.IsLeaf) || (error == LdapError.InvalidCredentials)) || (error == LdapError.SendTimeOut)) || ((error >= LdapError.ServerDown) && (error <= LdapError.ReferralLimitExceeded)));
 }
예제 #7
0
파일: utils.cs 프로젝트: chcosta/corefx
        internal static bool IsLdapError(LdapError error)
        {
            if (error == LdapError.IsLeaf || error == LdapError.InvalidCredentials || error == LdapError.SendTimeOut)
                return true;

            if (error >= LdapError.ServerDown && error <= LdapError.ReferralLimitExceeded)
                return true;

            return false;
        }
 internal static bool IsLdapError(LdapError error)
 {
     return((((error == LdapError.IsLeaf) || (error == LdapError.InvalidCredentials)) || (error == LdapError.SendTimeOut)) || ((error >= LdapError.ServerDown) && (error <= LdapError.ReferralLimitExceeded)));
 }